diff --git a/src/ChrisKonnertz/StringCalc/StringCalc.php b/src/ChrisKonnertz/StringCalc/StringCalc.php index fb66678..1494932 100644 --- a/src/ChrisKonnertz/StringCalc/StringCalc.php +++ b/src/ChrisKonnertz/StringCalc/StringCalc.php @@ -29,7 +29,7 @@ class StringCalc * * @const string */ - const VERSION = '1.0.9'; + const VERSION = '1.0.10'; /** * Closure that is called at the end of the grammar checking @@ -57,8 +57,8 @@ class StringCalc * * @param ContainerInterface $container * - * @throws Exceptions\ContainerException If the passed container parameter is not an object - * @throws Exceptions\ContainerException If the passed container parameter does not implement ContainerInterface + * @throws Exceptions\ContainerException If the passed container parameter is not an object or + * if the passed container parameter does not implement ContainerInterface */ public function __construct($container = null) { @@ -88,7 +88,6 @@ public function __construct($container = null) * Will return 0 if there is nothing to calculate. * * @param string $term - * * @return float|int * @throws Exceptions\ContainerException * @throws Exceptions\NotFoundException @@ -116,7 +115,6 @@ public function calculate($term) * Tokenize the term. Returns an array with the tokens. * * @param string $term - * * @return array * @throws Exceptions\ContainerException * @throws Exceptions\NotFoundException @@ -177,6 +175,7 @@ public function addSymbol(AbstractSymbol $symbol, $replaceSymbol = null) /** * Setter for the custom grammar checker property. + * * @see Parser::setCustomGrammarChecker() * * @param \Closure $customGrammarChecker diff --git a/tests/StringCalcTest.php b/tests/StringCalcTest.php index aefadd1..1d4c1e2 100644 --- a/tests/StringCalcTest.php +++ b/tests/StringCalcTest.php @@ -1,12 +1,12 @@ traverse( function ($node, $level) { - // do nothing + // Do nothing } ); } @@ -101,12 +109,18 @@ public function testGetContainer() public function testAddSymbol() { $stringCalc = $this->getInstance(); + $container = $stringCalc->getContainer(); $stringHelper = $container->get('stringcalc_stringhelper'); $symbol = new TestFunction($stringHelper); $stringCalc->addSymbol($symbol); $this->assertEquals(6, $stringCalc->calculate('3 * test()')); + + $symbol = new ChrisKonnertz\StringCalc\Symbols\Concrete\Constants\PiConstant($stringHelper); + $replaceSymbol = get_class($symbol); + + $stringCalc->addSymbol($symbol, $replaceSymbol); } public function testCalculations() @@ -269,28 +283,4 @@ private function doCalculations(array $calculations, $delta = 0.0) } } - public function _testRandomCalculations() - { - $this->stringCalc = $this->getInstance(); - $grammar = new \ChrisKonnertz\StringCalc\Grammar\StringCalcGrammar(); - - $numberOfCalculations = 100; - $calculations = []; - - // TODO Implement the rest of this method (and remove the underscore from method name to re-enable this test) - return; - - for ($i = 0; $i < $numberOfCalculations; $i++) { - $term = ''; - $result = eval($term); - - $calculation = [$term, $result]; - $calculations[] = $calculation; - } - - // Will call the assertEquals method with the delta parameter set which means assertEquals - // will report an error if result and expected result are not within $delta of each other - $this->doCalculations($calculations, self::RESULT_DELTA); - } - }