/** * @depends testFixtures2 */ public function testStructure(WAMService $wam) { $solve = $wam->runQuery('p(S,le,chat).'); $this->checkOneValueSuccess($solve, 'S', 'snm(determinant(le), nom(chat), masculin)'); $solve = $wam->runQuery('p(S,X,blanche).'); $this->checkOneSolutionSuccess($solve, array('S' => 'snm(determinant(souris), nom(blanche), feminin)', 'X' => 'souris')); }
/** * @depends testFixtures * @group stress */ public function testAllSolutions(WAMService $wam) { $solve = $wam->runQuery("soluce(X), solution(X)."); $this->assertCount(93, $solve); // there are 92 solutions to 8 queens problem for ($k = 0; $k < 92; $k++) { $row = $solve[$k]; $this->assertTrue($row->succeed); } // the last is false (because backtrack) $this->assertFalse($solve[92]->succeed); }
/** * @depends testFixtures3 */ public function testAssertBacktracked(WAMService $wam) { $solve = $wam->runQuery("retractall(robot)."); $solve = $wam->runQuery("assert(robot(c3po))."); $solve = $wam->runQuery("assert(robot(ig88))."); $solve = $wam->runQuery("donothing(robot(r2d2))."); $solve = $wam->runQuery("robot(X)."); $this->assertCount(2, $solve); foreach (array('c3po', 'ig88') as $k => $name) { $this->assertTrue($solve[$k]->succeed); $this->assertEquals($name, $solve[$k]->getQueryVars()['X']); } }
/** * @depends testFixtures */ public function testDiscount3(WAMService $wam) { $solve = $wam->runQuery("discount([ultrabook, geforce], X)."); $this->checkOneValueSuccess($solve, 'X', 1750 / 30, false); }
/** * @depends testFixtures1 */ public function testPredicateArg(WAMService $wam) { $solve = $wam->runQuery("equal(molecule(carbon, oxygen), molecule(carbon, X))."); $this->checkOneValueSuccess($solve, 'X', 'oxygen', false); }
/** * @depends testFixtures */ public function testOutput(WAMService $wam) { $solve = $wam->runQuery("hanoi(4)."); $this->checkSuccess($solve); $this->assertAttributeContains('transport de milieu sur droite', 'output', $solve[0]); }