Beispiel #1
0
 /**
  * Tests some slightly more complex expressions
  */
 public function test__error_handling()
 {
     $formula = new calc_formula('=pi( + a', array('a' => 10));
     $res = $formula->evaluate();
     $this->assertEqual($res, false);
     $this->assertEqual($formula->get_error(), get_string('unexpectedoperator', 'mathslib', '+'));
     $formula = new calc_formula('=pi(');
     $res = $formula->evaluate();
     $this->assertEqual($res, false);
     $this->assertEqual($formula->get_error(), get_string('expectingaclosingbracket', 'mathslib'));
     $formula = new calc_formula('=pi()^');
     $res = $formula->evaluate();
     $this->assertEqual($res, false);
     $this->assertEqual($formula->get_error(), get_string('operatorlacksoperand', 'mathslib', '^'));
 }