2 class ExpressionTest extends MediaWikiTestCase {
9 protected function setUp() {
11 $this->parser = new ExprParser();
15 * @dataProvider provideExpressions
17 function testExpression( $input, $expected ) {
20 $this->parser->doExpression( $input )
24 function provideExpressions() {
27 [ 'not (1 and 0)', '1' ],
37 [ '-4 * -4 = 4 * 4', '1' ],
38 [ 'not (1 != 1)', '1' ],
46 [ '3 / ( 2.0 * 0.1 )', '15' ],
47 [ '3 / ( 2.0 / 10 )', '15' ],
48 [ '3 / (- 0.2 )', '-15' ],
49 [ '3 / abs( 0.2 )', '15' ],
53 [ '4.0 round 0', '4' ],
56 [ '4.5 round 0', '5' ],
57 [ '4.2 round 0', '4' ],
58 [ '-4.2 round 0', '-4' ],
59 [ '-4.5 round 0', '-5' ],
60 [ '-2.0 round 0', '-2' ],
62 [ 'floor -6.0', '-6' ],
64 [ 'ceil -4.5', '-4' ],
65 [ 'floor -4.5', '-5' ],
67 [ 'ln(exp(1))', '1' ],
68 [ 'trunc(4.5)', '4' ],
69 [ 'trunc(-4.5)', '-4' ],
70 [ '123 fmod (2^64-1)', '123' ],
71 [ '5.7 mod 1.3', '0' ],
72 [ '5.7 fmod 1.3', '0.5' ],