Exemplo n.º 1
0
 /**
  * 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);
     }
 }
Exemplo n.º 2
0
 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));
 }
Exemplo n.º 3
0
 public function testParseFailure()
 {
     $this->setExpectedException(SyntaxErrorException::class);
     $z = Complex::parse('sdf');
 }