diff options
author | Alexander Kiryukhin <alexander@kiryukhin.su> | 2019-01-11 03:27:45 +0300 |
---|---|---|
committer | Bruce Wells <brucekwells@gmail.com> | 2019-01-11 03:27:45 +0300 |
commit | 76517641f79e8f0e4e5f3b620c731bf5c095df17 (patch) | |
tree | c0b03f4fa8acc12058924cbebb1511b31b6a41d8 /tests/MathTest.php | |
parent | bf6204aea73441f222d5b9ebb828f9da9d6894ad (diff) |
Fix single quotes parsing (#41)
* Fix single quotes parsing
Fix e-mails
Some small fixes
* Mistake in test
* More PHP versions
Diffstat (limited to 'tests/MathTest.php')
-rw-r--r-- | tests/MathTest.php | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/tests/MathTest.php b/tests/MathTest.php index 9acdb63..55e0799 100644 --- a/tests/MathTest.php +++ b/tests/MathTest.php @@ -32,7 +32,7 @@ class MathTest extends \PHPUnit_Framework_TestCase /** @var float $phpResult */ eval('$phpResult = ' . $expression . ';'); - $this->assertEquals($calculator->execute($expression), $phpResult); + $this->assertEquals($calculator->execute($expression), $phpResult, "Expression was: ${expression}"); } /** @@ -138,9 +138,23 @@ class MathTest extends \PHPUnit_Framework_TestCase { $calculator = new MathExecutor(); - $calculator->addFunction('round', function ($arg) { return round($arg); }, 1); + $calculator->addFunction('round', function ($arg) { + return round($arg); + }, 1); /** @var float $phpResult */ eval('$phpResult = round(100/30);'); $this->assertEquals($calculator->execute('round(100/30)'), $phpResult); } + + public function testQuotes() + { + $calculator = new MathExecutor(); + $testString = "some, long. arg; with: different-separators!"; + $calculator->addFunction('test', function ($arg) use ($testString) { + $this->assertEquals($arg, $testString); + return 0; + }, 1); + $calculator->execute('test("' . $testString . '")'); // single quotes + $calculator->execute("test('" . $testString . "')"); // double quotes + } }
\ No newline at end of file |