MediaWiki
REL1_30
ExpressionTest.php
Go to the documentation of this file.
1
<?php
2
class
ExpressionTest
extends
MediaWikiTestCase
{
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
[
26
[
'1 or 0'
,
'1'
],
27
[
'not (1 and 0)'
,
'1'
],
28
[
'not 0'
,
'1'
],
29
[
'4 < 5'
,
'1'
],
30
[
'-5 < 2'
,
'1'
],
31
[
'-2 <= -2'
,
'1'
],
32
[
'4 > 3'
,
'1'
],
33
[
'4 > -3'
,
'1'
],
34
[
'5 >= 2'
,
'1'
],
35
[
'2 >= 2'
,
'1'
],
36
[
'1 != 2'
,
'1'
],
37
[
'-4 * -4 = 4 * 4'
,
'1'
],
38
[
'not (1 != 1)'
,
'1'
],
39
[
'1 + 1'
,
'2'
],
40
[
'-1 + 1'
,
'0'
],
41
[
'+1 + 1'
,
'2'
],
42
[
'4 * 4'
,
'16'
],
43
[
'(1/3) * 3'
,
'1'
],
44
[
'3 / 1.5'
,
'2'
],
45
[
'3 / 0.2'
,
'15'
],
46
[
'3 / ( 2.0 * 0.1 )'
,
'15'
],
47
[
'3 / ( 2.0 / 10 )'
,
'15'
],
48
[
'3 / (- 0.2 )'
,
'-15'
],
49
[
'3 / abs( 0.2 )'
,
'15'
],
50
[
'3 mod 2'
,
'1'
],
51
[
'1e4'
,
'10000'
],
52
[
'1e-2'
,
'0.01'
],
53
[
'4.0 round 0'
,
'4'
],
54
[
'ceil 4'
,
'4'
],
55
[
'floor 4'
,
'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'
],
61
[
'ceil -3'
,
'-3'
],
62
[
'floor -6.0'
,
'-6'
],
63
[
'ceil 4.2'
,
'5'
],
64
[
'ceil -4.5'
,
'-4'
],
65
[
'floor -4.5'
,
'-5'
],
66
[
'abs(-2)'
,
'2'
],
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'
],
73
];
74
}
75
}
ExprParser
Definition
Expr.php:69
ExpressionTest
Definition
ExpressionTest.php:2
ExpressionTest\provideExpressions
provideExpressions()
Definition
ExpressionTest.php:24
ExpressionTest\testExpression
testExpression( $input, $expected)
provideExpressions
Definition
ExpressionTest.php:17
ExpressionTest\$parser
ExprParser $parser
Definition
ExpressionTest.php:7
ExpressionTest\setUp
setUp()
Definition
ExpressionTest.php:9
MediaWikiTestCase
Definition
MediaWikiTestCase.php:15
$input
if(is_array($mode)) switch( $mode) $input
Definition
postprocess-phan.php:141
extensions
ParserFunctions
tests
phpunit
ExpressionTest.php
Generated on Mon Nov 25 2024 15:41:59 for MediaWiki by
1.10.0