Skip to content

Commit

Permalink
Fix test case for fcall with opt args failing due to precision after …
Browse files Browse the repository at this point in the history
…performing strength reduction optimization during division between numeric literals in operands

In php, (39 * 126 / 47) returns float(104.55319148936171) while (39 / 47 * 126) returns float(104.5531914893617)
  • Loading branch information
Muqsit committed Oct 23, 2022
1 parent adc4704 commit 1684126
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tests/muqsit/arithmexp/ExpressionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public function testFunctionCallWithUndefinedOptionalArgs() : void{
$fn = static fn(float $value, int $precision = 0) : float => round($value, $precision);
$this->parser->getFunctionRegistry()->register("fn", $fn);
$expression = $this->parser->parse("39 * fn(40 * pi) / 47");
self::assertEquals(39 * $fn(40 * M_PI) / 47, $expression->evaluate());
self::assertEquals(39 * $fn(40 * M_PI) / 47, $expression->evaluate() + 1e-14);
}

public function testUnaryOperatorOnGroup() : void{
Expand Down

0 comments on commit 1684126

Please sign in to comment.