From 334dd26e3c78a36002aed34aa26aa526b11c5dfb Mon Sep 17 00:00:00 2001 From: Bruce Wells Date: Thu, 25 Oct 2018 11:42:11 -0400 Subject: Removing DivisionByZeroException testing for now Added more unit tests. --- tests/MathTest.php | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/MathTest.php b/tests/MathTest.php index df073b2..c8b8a03 100644 --- a/tests/MathTest.php +++ b/tests/MathTest.php @@ -52,8 +52,11 @@ class MathTest extends \PHPUnit_Framework_TestCase public function testZeroDivision() { $calculator = new MathExecutor(); - $this->expectException(DivisionByZeroException::class); - $calculator->execute('1 / 0'); + $this->assertEquals($calculator->execute('1 / 0'), 0); + + // future version with allow for optional exceptions on divide by zero + // $this->expectException(DivisionByZeroException::class); + // $calculator->execute('1 / 0'); } public function testExponentiation() @@ -86,15 +89,25 @@ class MathTest extends \PHPUnit_Framework_TestCase ['(5 + 3) * -1'], - ['2+2*2'], + ['2- 2*2'], + ['2-(2*2)'], + ['(2- 2)*2'], + ['2 + 2*2'], + ['2+ 2*2'], ['(2+2)*2'], - ['(2+2)*-2'], + ['(2 + 2)*-2'], ['(2+-2)*2'], ['sin(10) * cos(50) / min(10, 20/2)'], ['100500 * 3.5E5'], ['100500 * 3.5E-5'], + + ['-1 + -2'], + ['-1+-2'], + ['-1- -2'], + ['-1/-2'], + ['-1*-2'], ]; } -- cgit v1.2.3