MediaWiki  1.29.1
ExpressionTest.php
Go to the documentation of this file.
1 <?php
3 
7  protected $parser;
8 
9  protected function setUp() {
10  parent::setUp();
11  $this->parser = new ExprParser();
12  }
13 
17  function testExpression( $input, $expected ) {
18  $this->assertEquals(
19  $expected,
20  $this->parser->doExpression( $input )
21  );
22  }
23 
24  function provideExpressions() {
25  return array(
26  array( '1 or 0', '1' ),
27  array( 'not (1 and 0)', '1' ),
28  array( 'not 0', '1' ),
29  array( '4 < 5', '1' ),
30  array( '-5 < 2', '1' ),
31  array( '-2 <= -2', '1' ),
32  array( '4 > 3', '1' ),
33  array( '4 > -3', '1' ),
34  array( '5 >= 2', '1' ),
35  array( '2 >= 2', '1' ),
36  array( '1 != 2', '1' ),
37  array( '-4 * -4 = 4 * 4', '1' ),
38  array( 'not (1 != 1)', '1' ),
39  array( '1 + 1', '2' ),
40  array( '-1 + 1', '0' ),
41  array( '+1 + 1', '2' ),
42  array( '4 * 4', '16' ),
43  array( '(1/3) * 3', '1' ),
44  array( '3 / 1.5', '2' ),
45  array( '3 / 0.2', '15' ),
46  array( '3 / ( 2.0 * 0.1 )', '15' ),
47  array( '3 / ( 2.0 / 10 )', '15' ),
48  array( '3 / (- 0.2 )', '-15' ),
49  array( '3 / abs( 0.2 )', '15' ),
50  array( '3 mod 2', '1' ),
51  array( '1e4', '10000' ),
52  array( '1e-2', '0.01' ),
53  array( '4.0 round 0', '4' ),
54  array( 'ceil 4', '4' ),
55  array( 'floor 4', '4' ),
56  array( '4.5 round 0', '5' ),
57  array( '4.2 round 0', '4' ),
58  array( '-4.2 round 0', '-4' ),
59  array( '-4.5 round 0', '-5' ),
60  array( '-2.0 round 0', '-2' ),
61  array( 'ceil -3', '-3' ),
62  array( 'floor -6.0', '-6' ),
63  array( 'ceil 4.2', '5' ),
64  array( 'ceil -4.5', '-4' ),
65  array( 'floor -4.5', '-5' ),
66  array( 'abs(-2)', '2' ),
67  array( 'ln(exp(1))', '1' ),
68  array( 'trunc(4.5)', '4' ),
69  array( 'trunc(-4.5)', '-4' ),
70  array( '123 fmod (2^64-1)', '123' ),
71  array( '5.7 mod 1.3', '0' ),
72  array( '5.7 fmod 1.3', '0.5' ),
73  );
74  }
75 }
76 
ExpressionTest
Definition: ExpressionTest.php:2
ExpressionTest\provideExpressions
provideExpressions()
Definition: ExpressionTest.php:24
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
ExpressionTest\testExpression
testExpression( $input, $expected)
provideExpressions
Definition: ExpressionTest.php:17
$input
if(is_array( $mode)) switch( $mode) $input
Definition: postprocess-phan.php:141
MediaWikiTestCase
Definition: MediaWikiTestCase.php:13
some
I won t presume to tell you how to I m just describing the methods I chose to use for myself If you do choose to follow these it will probably be easier for you to collaborate with others on the but if you want to contribute without by all means do which work well I also use K &R brace matching style I know that s a religious issue for some
Definition: design.txt:79
ExprParser
Definition: Expr.php:69
ExpressionTest\$parser
ExprParser $parser
Definition: ExpressionTest.php:7
ExpressionTest\setUp
setUp()
Definition: ExpressionTest.php:9
captcha-old.parser
parser
Definition: captcha-old.py:187
array
the array() calling protocol came about after MediaWiki 1.4rc1.