diff options
author | NeonXP <frei@neonxp.info> | 2013-09-18 20:34:51 +0400 |
---|---|---|
committer | NeonXP <frei@neonxp.info> | 2013-09-18 20:34:51 +0400 |
commit | 0b7e6b1b860f303d6c71a0d0d1692220dcb53dc4 (patch) | |
tree | 5f67875351cacf8370b4cd631d3c7657fbc01441 /tests/MathTest.php | |
parent | 4b092895bc510efb6cc329b325a0426e720f05d5 (diff) |
+ added test for custom user functions
Diffstat (limited to 'tests/MathTest.php')
-rw-r--r-- | tests/MathTest.php | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/MathTest.php b/tests/MathTest.php index 1b96ee2..2b2727f 100644 --- a/tests/MathTest.php +++ b/tests/MathTest.php @@ -62,4 +62,14 @@ class MathTest extends \PHPUnit_Framework_TestCase array('100500 * 3.5E-5') ); } + + public function testFunction() + { + $calculator = new MathExecutor(); + + $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); + } }
\ No newline at end of file |