MediaWiki
REL1_31
ExpressionTest.php
Go to the documentation of this file.
1
<?php
2
6
class
ExpressionTest
extends
MediaWikiTestCase
{
7
11
protected
$parser
;
12
13
protected
function
setUp
() {
14
parent::setUp();
15
$this->parser =
new
ExprParser
();
16
}
17
21
function
testExpression
(
$input
, $expected ) {
22
$this->assertEquals(
23
$expected,
24
$this->parser->doExpression(
$input
)
25
);
26
}
27
28
function
provideExpressions
() {
29
return
[
30
[
'1 or 0'
,
'1'
],
31
[
'not (1 and 0)'
,
'1'
],
32
[
'not 0'
,
'1'
],
33
[
'4 < 5'
,
'1'
],
34
[
'-5 < 2'
,
'1'
],
35
[
'-2 <= -2'
,
'1'
],
36
[
'4 > 3'
,
'1'
],
37
[
'4 > -3'
,
'1'
],
38
[
'5 >= 2'
,
'1'
],
39
[
'2 >= 2'
,
'1'
],
40
[
'1 != 2'
,
'1'
],
41
[
'-4 * -4 = 4 * 4'
,
'1'
],
42
[
'not (1 != 1)'
,
'1'
],
43
[
'1 + 1'
,
'2'
],
44
[
'-1 + 1'
,
'0'
],
45
[
'+1 + 1'
,
'2'
],
46
[
'4 * 4'
,
'16'
],
47
[
'(1/3) * 3'
,
'1'
],
48
[
'3 / 1.5'
,
'2'
],
49
[
'3 / 0.2'
,
'15'
],
50
[
'3 / ( 2.0 * 0.1 )'
,
'15'
],
51
[
'3 / ( 2.0 / 10 )'
,
'15'
],
52
[
'3 / (- 0.2 )'
,
'-15'
],
53
[
'3 / abs( 0.2 )'
,
'15'
],
54
[
'3 mod 2'
,
'1'
],
55
[
'1e4'
,
'10000'
],
56
[
'1e-2'
,
'0.01'
],
57
[
'4.0 round 0'
,
'4'
],
58
[
'ceil 4'
,
'4'
],
59
[
'floor 4'
,
'4'
],
60
[
'4.5 round 0'
,
'5'
],
61
[
'4.2 round 0'
,
'4'
],
62
[
'-4.2 round 0'
,
'-4'
],
63
[
'-4.5 round 0'
,
'-5'
],
64
[
'-2.0 round 0'
,
'-2'
],
65
[
'ceil -3'
,
'-3'
],
66
[
'floor -6.0'
,
'-6'
],
67
[
'ceil 4.2'
,
'5'
],
68
[
'ceil -4.5'
,
'-4'
],
69
[
'floor -4.5'
,
'-5'
],
70
[
'abs(-2)'
,
'2'
],
71
[
'ln(exp(1))'
,
'1'
],
72
[
'trunc(4.5)'
,
'4'
],
73
[
'trunc(-4.5)'
,
'-4'
],
74
[
'123 fmod (2^64-1)'
,
'123'
],
75
[
'5.7 mod 1.3'
,
'0'
],
76
[
'5.7 fmod 1.3'
,
'0.5'
],
77
];
78
}
79
}
ExprParser
Definition
ExprParser.php:65
ExpressionTest
ExprParser.
Definition
ExpressionTest.php:6
ExpressionTest\provideExpressions
provideExpressions()
Definition
ExpressionTest.php:28
ExpressionTest\testExpression
testExpression( $input, $expected)
provideExpressions
Definition
ExpressionTest.php:21
ExpressionTest\$parser
ExprParser $parser
Definition
ExpressionTest.php:11
ExpressionTest\setUp
setUp()
Definition
ExpressionTest.php:13
MediaWikiTestCase
Definition
MediaWikiTestCase.php:17
$input
if(is_array($mode)) switch( $mode) $input
Definition
postprocess-phan.php:145
extensions
ParserFunctions
tests
phpunit
ExpressionTest.php
Generated on Mon Nov 25 2024 15:34:22 for MediaWiki by
1.10.0