MediaWiki REL1_33
ExpressionTest.php
Go to the documentation of this file.
1<?php
2
4
9
13 public function testExpression( $input, $expected ) {
14 $parser = new ExprParser();
15 $this->assertEquals(
16 $expected,
17 $parser->doExpression( $input )
18 );
19 }
20
21 public function provideExpressions() {
22 return [
23 [ '1 or 0', '1' ],
24 [ 'not (1 and 0)', '1' ],
25 [ 'not 0', '1' ],
26 [ '4 < 5', '1' ],
27 [ '-5 < 2', '1' ],
28 [ '-2 <= -2', '1' ],
29 [ '4 > 3', '1' ],
30 [ '4 > -3', '1' ],
31 [ '5 >= 2', '1' ],
32 [ '2 >= 2', '1' ],
33 [ '1 != 2', '1' ],
34 [ '-4 * -4 = 4 * 4', '1' ],
35 [ 'not (1 != 1)', '1' ],
36 [ '1 + 1', '2' ],
37 [ '-1 + 1', '0' ],
38 [ '+1 + 1', '2' ],
39 [ '4 * 4', '16' ],
40 [ '(1/3) * 3', '1' ],
41 [ '3 / 1.5', '2' ],
42 [ '3 / 0.2', '15' ],
43 [ '3 / ( 2.0 * 0.1 )', '15' ],
44 [ '3 / ( 2.0 / 10 )', '15' ],
45 [ '3 / (- 0.2 )', '-15' ],
46 [ '3 / abs( 0.2 )', '15' ],
47 [ '3 mod 2', '1' ],
48 [ '1e4', '10000' ],
49 [ '1e-2', '0.01' ],
50 [ '4.0 round 0', '4' ],
51 [ 'ceil 4', '4' ],
52 [ 'floor 4', '4' ],
53 [ '4.5 round 0', '5' ],
54 [ '4.2 round 0', '4' ],
55 [ '-4.2 round 0', '-4' ],
56 [ '-4.5 round 0', '-5' ],
57 [ '-2.0 round 0', '-2' ],
58 [ 'ceil -3', '-3' ],
59 [ 'floor -6.0', '-6' ],
60 [ 'ceil 4.2', '5' ],
61 [ 'ceil -4.5', '-4' ],
62 [ 'floor -4.5', '-5' ],
63 [ 'abs(-2)', '2' ],
64 [ 'ln(exp(1))', '1' ],
65 [ 'trunc(4.5)', '4' ],
66 [ 'trunc(-4.5)', '-4' ],
67 [ '123 fmod (2^64-1)', '123' ],
68 [ '5.7 mod 1.3', '0' ],
69 [ '5.7 fmod 1.3', '0.5' ],
70 ];
71 }
72}
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
\MediaWiki\Extensions\ParserFunctions\ExprParser
testExpression( $input, $expected)
provideExpressions
see documentation in includes Linker php for Linker::makeImageLink or false for current used if you return false $parser
Definition hooks.txt:1834
if(is_array($mode)) switch( $mode) $input