$vy = $p->getValue('y'); $this->assertEqual($va, 11.2); $this->assertEqual($vb, 2.5); $this->assertEqual($vx, 'unset'); $this->assertEqual($vy, NULL); $this->assertTrue($p->checkValue('a', 11.2)); $this->assertFalse($p->checkValue('b', 11.2)); $this->expectException(); $p->checkValue('x', 11.2); $p->checkValue('D', 11.2); } function testEquation_CheckEquation() { $p = new EquationProblem(); $p->addVariable('a', 3); $p->addVariable('b', 4); $this->assertEqual($p->checkEquation('a+3'), 'not equation'); $this->assertEqual($p->checkEquation('a-c*x=3'), 'undefined: c, x'); $this->assertEqual($p->checkEquation('a=3'), 'true'); $this->assertEqual($p->checkEquation('a^2 = 9'), 'true'); $this->assertEqual($p->checkEquation('a^2 + 1 = 9'), 'false'); $this->assertEqual($p->checkEquation('a^2 + b^2 = 25'), 'true'); $this->assertEqual($p->checkEquation('\\(a^2 + b^2) = 5'), 'true'); $this->assertEqual($p->checkEquation('a>3'), 'false'); $this->assertEqual($p->checkEquation('a >= 3'), 'true'); $this->assertEqual($p->checkEquation('a> 1'), 'true'); $this->assertEqual($p->checkEquation('a> -3'), 'true'); } } $test = new TestProblem(); $test->run(new TextReporter());
public static function test() { $t = new TestProblem(); $t->define(); $solution = $t->solve(); var_dump($solution); // X[1] Y[4] Z[5] R[6] $solution = $t->solveMax(); var_dump($solution); // X[4] Y[6] Z[10] R[9] sum[29] }