diff options
author | Bruce Wells <brucekwells@gmail.com> | 2019-01-16 02:36:10 +0300 |
---|---|---|
committer | Bruce Wells <brucekwells@gmail.com> | 2019-01-16 02:36:10 +0300 |
commit | 265cff175eb1c0be4b59d937286059532361820f (patch) | |
tree | acc0cb26df725263f100589b4a54360cadaca68b /tests | |
parent | 0437f808f229de08dd980618ac8f90a1ccd9b0c8 (diff) |
Fixed function parameter order
Corrected $places default value for addFunction to match TokenFactory
Added function order test and put expected order first in assertEquals
If else blocks in calculator
Updated docs
Diffstat (limited to 'tests')
-rw-r--r-- | tests/MathTest.php | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/tests/MathTest.php b/tests/MathTest.php index 8eb7827..81f0230 100644 --- a/tests/MathTest.php +++ b/tests/MathTest.php @@ -138,7 +138,11 @@ class MathTest extends \PHPUnit_Framework_TestCase { $calculator = new MathExecutor(); - $calculator->addFunction('concat', function ($arg1, $arg2) {return $arg1.$arg2;}); + $calculator->addFunction('concat', function ($arg1, $arg2) + { + return $arg1.$arg2; + } + ); $this->assertEquals('testing', $calculator->execute('concat("test","ing")')); $this->assertEquals('testing', $calculator->execute("concat('test','ing')")); } @@ -147,19 +151,19 @@ class MathTest extends \PHPUnit_Framework_TestCase { $calculator = new MathExecutor(); $calculator->addFunction('round', function ($arg) {return round($arg);}); - /** @var float $phpResult */ - eval('$phpResult = round(100/30);'); - $this->assertEquals($phpResult, $calculator->execute('round(100/30)')); + $this->assertEquals(round(100/30), $calculator->execute('round(100/30)')); } public function testQuotes() { $calculator = new MathExecutor(); $testString = "some, long. arg; with: different-separators!"; - $calculator->addFunction('test', function ($arg) use ($testString) { - $this->assertEquals($testString, $arg); - return 0;} - ); + $calculator->addFunction('test', function ($arg) use ($testString) + { + $this->assertEquals($testString, $arg); + return 0; + } + ); $calculator->execute('test("' . $testString . '")'); // single quotes $calculator->execute("test('" . $testString . "')"); // double quotes } |