/** * Update the variables used for evaluating * * @param array $variables Key/value pair holding current variable values * @retval void */ public function setVariables($variables) { $this->variables = []; foreach ($variables as $var => $value) { $this->variables[$var] = Complex::parse($value); } }
public function testCanEvaluateExponentiation() { $x = $this->variables['x']; $this->assertResult('x^3', Complex::pow($x, 3)); $this->assertResult('x^x^x', Complex::pow($x, Complex::pow($x, $x))); $this->assertResult('(-1)^(-1)', Complex::parse(-1)); }
public function testParseFailure() { $this->setExpectedException(SyntaxErrorException::class); $z = Complex::parse('sdf'); }