aboutsummaryrefslogtreecommitdiff
path: root/tests/MathTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/MathTest.php')
-rw-r--r--tests/MathTest.php11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/MathTest.php b/tests/MathTest.php
index f37d0ec..d086acb 100644
--- a/tests/MathTest.php
+++ b/tests/MathTest.php
@@ -266,6 +266,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();