diff options
-rw-r--r-- | README.md | 4 | ||||
-rw-r--r-- | tests/MathTest.php | 8 |
2 files changed, 11 insertions, 1 deletions
@@ -45,6 +45,8 @@ $executor->addFunction('abs', function($arg) {return abs($arg);}); ``` Function default parameters are not supported at this time. +Default parameters are not currently supported. + ## Operators: Default operators: `+ - * / ^` @@ -112,7 +114,7 @@ Default variables: ``` $pi = 3.14159265359 -$e = 2.71828182846 +$e = 2.71828182846 ``` You can add your own variables to executor: diff --git a/tests/MathTest.php b/tests/MathTest.php index 3cf4dbd..eba32c0 100644 --- a/tests/MathTest.php +++ b/tests/MathTest.php @@ -166,6 +166,14 @@ class MathTest extends \PHPUnit_Framework_TestCase $this->assertEquals($phpResult, $calculator->execute($expression)); } + public function testFunctionsWithQuotes() + { + $calculator = new MathExecutor(); + $calculator->addFunction('concat', function($first, $second){return $first.$second;}); + $this->assertEquals('testing', $calculator->execute('concat("test", "ing")')); + $this->assertEquals('testing', $calculator->execute("concat('test', 'ing')")); + } + public function testQuotes() { $calculator = new MathExecutor(); |