diff options
author | Bruce Wells <brucekwells@gmail.com> | 2023-09-27 23:28:28 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-27 23:28:28 +0300 |
commit | f6750c9c3c944827462f28ceb3db6284458412cb (patch) | |
tree | e577be6216bc9b556759812a7531728d0c7dc59b | |
parent | 1968057f42210e3f5675d46126a1dc6506616ef3 (diff) |
Improved tests for ! operator (#131)
-rw-r--r-- | tests/MathTest.php | 29 |
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(); |