18 $parser->doExpression( $input )
25 [
'not (1 and 0)',
'1' ],
35 [
'-4 * -4 = 4 * 4',
'1' ],
36 [
'not (1 != 1)',
'1' ],
44 [
'3 / ( 2.0 * 0.1 )',
'15' ],
45 [
'3 / ( 2.0 / 10 )',
'15' ],
46 [
'3 / (- 0.2 )',
'-15' ],
47 [
'3 / abs( 0.2 )',
'15' ],
51 [
'4.0 round 0',
'4' ],
54 [
'4.5 round 0',
'5' ],
55 [
'4.2 round 0',
'4' ],
56 [
'-4.2 round 0',
'-4' ],
57 [
'-4.5 round 0',
'-5' ],
58 [
'-2.0 round 0',
'-2' ],
60 [
'floor -6.0',
'-6' ],
62 [
'ceil -4.5',
'-4' ],
63 [
'floor -4.5',
'-5' ],
65 [
'ln(exp(1))',
'1' ],
66 [
'trunc(4.5)',
'4' ],
67 [
'trunc(-4.5)',
'-4' ],
68 [
'123 fmod (2^64-1)',
'123' ],
69 [
'5.7 mod 1.3',
'0' ],
70 [
'5.7 fmod 1.3',
'0.5' ],
71 [
'pi + 1',
'4.1415926535898' ],
89 $parser->doExpression( $input );
93 $longExpression = str_repeat(
'ln(', 1001 ) .
'1' . str_repeat(
')', 1001 );
95 'Expression too long' => [ $longExpression ],
96 'Unexpected number' => [
'1 2' ],
97 'Unrecognised word' => [
'foo' ],
98 'Unexpected number: pi' => [
'1 pi' ],
99 'Unexpected operator' => [
'1 sin' ],
100 'Unexpected operator: (' => [
'1 (' ],
101 'Unexpected closing bracket' => [
'1 + 1)' ],
102 'Unexpected punctuation' => [
'1, 2' ],
103 'Unexpected binary operator' => [
'<1' ],
104 'Unclosed bracket' => [
'(1' ],
105 'Missing operand: unary -' => [
'-' ],
106 'Missing operand: unary +' => [
'+' ],
107 'Missing operand: *' => [
'1*' ],
108 'Missing operand: /' => [
'1/' ],
109 'Division by zero: /' => [
'1/0' ],
110 'Missing operand: mod' => [
'1 mod' ],
111 'Division by zero: mod' => [
'1 mod 0' ],
112 'Missing operand: fmod' => [
'1 fmod' ],
113 'Division by zero: fmod' => [
'1 fmod 0' ],
114 'Missing operand: +' => [
'1+' ],
115 'Missing operand: -' => [
'1-' ],
116 'Missing operand: and' => [
'1 and' ],
117 'Missing operand: or' => [
'1 or' ],
118 'Missing operand: =' => [
'1 =' ],
119 'Missing operand: not' => [
'1 not' ],
120 'Missing operand: round' => [
'1 round' ],
121 'Missing operand: <' => [
'1<' ],
122 'Missing operand: >' => [
'1>' ],
123 'Missing operand: <=' => [
'1<=' ],
124 'Missing operand: >=' => [
'1>=' ],
125 'Missing operand: <>' => [
'1<>' ],
126 'Missing operand: sin' => [
'sin()' ],
127 'Missing operand: cos' => [
'cos()' ],
128 'Missing operand: tan' => [
'tan()' ],
129 'Missing operand: asin' => [
'asin()' ],
130 'Invalid operand: asin' => [
'asin(3) ' ],
131 'Missing operand: acos' => [
'acos()' ],
132 'Invalid operand: acos' => [
'acos(-1.1)' ],
133 'Missing operand: atan' => [
'atan()' ],
134 'Missing operand: exp' => [
'exp()' ],
135 'Missing operand: ln' => [
'ln()' ],
136 'Invalid operand: ln' => [
'ln(-1)' ],
137 'Missing operand: abs' => [
'abs()' ],
138 'Missing operand: floor' => [
'floor' ],
139 'Missing operand: trunc' => [
'trunc' ],
140 'Missing operand: ceil' => [
'ceil' ],
141 'Missing operand: ^' => [
'1 ^' ],
143 'Missing operand: sqrt' => [
'sqrt' ],
144 'Result is not a number: sqrt' => [
'sqrt(-1)' ],
@group ParserFunctions @covers \MediaWiki\Extensions\ParserFunctions\ExprParser
testExpression( $input, $expected)
@dataProvider provideExpressions
testExpressionThrows( $input)
@dataProvider provideExpressionThrows
provideExpressionThrows()