From abdc2a0a7dbc16d577df72d9909bdeea1fcf1350 Mon Sep 17 00:00:00 2001 From: Muqsit Date: Thu, 3 Nov 2022 12:24:12 +0000 Subject: [PATCH] Add failing test case relating to #16 --- tests/muqsit/arithmexp/OptimizerTest.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/muqsit/arithmexp/OptimizerTest.php b/tests/muqsit/arithmexp/OptimizerTest.php index dc463f9..15c46e5 100644 --- a/tests/muqsit/arithmexp/OptimizerTest.php +++ b/tests/muqsit/arithmexp/OptimizerTest.php @@ -198,6 +198,12 @@ public function testDivisionOperatorStrengthReductionForEqualOperandsWithGroupin self::assertEquals(1, $expression->evaluate()); } + public function testDivisionOperatorStrengthReductionForEqualOperandsReturningNan() : void{ + $expression = $this->parser->parse("sqrt(-1) / sqrt(-1)"); + self::assertInstanceOf(ConstantExpression::class, $expression); + self::assertNan($expression->evaluate()); + } + public function testDivisionOperatorStrengthReductionForCommutativelyEqualOperands() : void{ $expression = $this->parser->parse("(x + y + z) / (y + x + z)"); self::assertInstanceOf(ConstantExpression::class, $expression);