aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/MathTest.php29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/MathTest.php b/tests/MathTest.php
index 8c22224..bf33793 100644
--- a/tests/MathTest.php
+++ b/tests/MathTest.php
@@ -256,8 +256,15 @@ class MathTest extends TestCase
['7 % 4'],
['99 % 4'],
['123 % 7'],
+
['!(1||0)'],
['!(1&&0)'],
+ ['!(1)'],
+ ['!(0)'],
+ ['! 1'],
+ ['! 0'],
+ ['!1'],
+ ['!0'],
];
}
@@ -495,8 +502,15 @@ class MathTest extends TestCase
['7 % 4'],
['99 % 4'],
['123 % 7'],
+
['!(1||0)'],
['!(1&&0)'],
+ ['!(1)'],
+ ['!(0)'],
+ ['! 1'],
+ ['! 0'],
+ ['!1'],
+ ['!0'],
];
}
@@ -582,6 +596,21 @@ class MathTest extends TestCase
$this->assertEquals(0.0, $calculator->execute('$ + $four'));
}
+ public function testNotVariableOperator() : void
+ {
+ $calculator = new MathExecutor();
+ $calculator->setVar('one', 1);
+ $calculator->setVar('zero', 0);
+ $this->assertEquals(false, $calculator->execute('! $one'));
+ $this->assertEquals(false, $calculator->execute('!$one'));
+ $this->assertEquals(false, $calculator->execute('! ($one)'));
+ $this->assertEquals(false, $calculator->execute('!($one)'));
+ $this->assertEquals(true, $calculator->execute('! $zero'));
+ $this->assertEquals(true, $calculator->execute('!$zero'));
+ $this->assertEquals(true, $calculator->execute('! ($zero)'));
+ $this->assertEquals(true, $calculator->execute('!($zero)'));
+ }
+
public function testExponentiation() : void
{
$calculator = new MathExecutor();