Skip to content

Commit

Permalink
Division between deterministic tokens is now solely handled by consta…
Browse files Browse the repository at this point in the history
…nt folding
  • Loading branch information
Muqsit committed Nov 3, 2022
1 parent e38a5ba commit 1990dfa
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions tests/muqsit/arithmexp/OptimizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ public function testConstantPropagationOptimization() : void{
self::assertExpressionsEqual($expected, $actual);
}

public function testDivisionConstantFoldingForEqualOperandsReturningNan() : void{
$expression = $this->parser->parse("sqrt(-1) / sqrt(-1)");
self::assertInstanceOf(ConstantExpression::class, $expression);
self::assertNan($expression->evaluate());
}

public function testNoOptimization() : void{
$actual = $this->parser->parse("37.28 * cos(mt_rand(x, y) / 23.84) ** 3");
$expected = $this->unoptimized_parser->parse("cos(mt_rand(x, y) / 23.84) ** 3 * 37.28");
Expand Down Expand Up @@ -198,12 +204,6 @@ 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);
Expand Down

0 comments on commit 1990dfa

Please sign in to comment.