diff options
Diffstat (limited to 'tests/MathTest.php')
-rw-r--r-- | tests/MathTest.php | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/MathTest.php b/tests/MathTest.php index a843db5..dee3f39 100644 --- a/tests/MathTest.php +++ b/tests/MathTest.php @@ -252,6 +252,17 @@ class MathTest extends TestCase $this->assertEquals(0, $calculator->execute('10 / 0')); } + public function testUnaryOperators() + { + $calculator = new MathExecutor(); + $this->assertEquals(5, $calculator->execute('+5')); + $this->assertEquals(5, $calculator->execute('+(3+2)')); + $this->assertEquals(-5, $calculator->execute('-5')); + $this->assertEquals(5, $calculator->execute('-(-5)')); + $this->assertEquals(-5, $calculator->execute('+(-5)')); + $this->assertEquals(-5, $calculator->execute('-(3+2)')); + } + public function testZeroDivisionException() { $calculator = new MathExecutor(); |