Skip to content

Commit

Permalink
allow math processor to run multiple times by not using mutable refer…
Browse files Browse the repository at this point in the history
…ences
  • Loading branch information
Stefan Ackermann committed Dec 13, 2019
1 parent 662c517 commit 7d6d32c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/MathParser/Math.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function registerVariable($name, $value)
$this->variables[$name] = $value;
}

public function run(array &$stack)
public function run(array $stack)
{
$this->substituteVariables($stack, $this->variables);

Expand Down
11 changes: 11 additions & 0 deletions test/MathParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,17 @@ public function testVariables($input, $expected)
$this->assertSame($expected, $mathParser->evaluate($input[0]));
}

/**
* @dataProvider provideVariableData
*/
public function testVariablesMultipleTimes($input, $expected)
{
$mathParser = new Math();
$mathParser->setVariables($input[1]);
$this->assertSame($expected, $mathParser->evaluate($input[0]));
$this->assertSame($expected, $mathParser->evaluate($input[0]));
}

/**
* @dataProvider provideInvalidVariableData
*/
Expand Down

0 comments on commit 7d6d32c

Please sign in to comment.