aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJavier Marín <javier@marinros.com>2021-03-05 03:42:01 +0300
committerGitHub <noreply@github.com>2021-03-05 03:42:01 +0300
commitd99491c1f45d091cfe80227671336455b20b897e (patch)
tree6a924c8daba04fa21c99504aba957fb07ea4af77 /tests
parent17cc5b9dc48b19e0dee1937080601a9fc2890af4 (diff)
Support for unary positive expressions (#85)
* Support for unary positive operator
Diffstat (limited to 'tests')
-rw-r--r--tests/MathTest.php11
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();