コード例 #1
0
 /**
  * @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'));
 }
コード例 #2
0
 /**
  * @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);
 }
コード例 #3
0
 /**
  * @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']);
     }
 }
コード例 #4
0
ファイル: WAMBasketTest.php プロジェクト: trismegiste/prolog
 /**
  * @depends testFixtures
  */
 public function testDiscount3(WAMService $wam)
 {
     $solve = $wam->runQuery("discount([ultrabook, geforce], X).");
     $this->checkOneValueSuccess($solve, 'X', 1750 / 30, false);
 }
コード例 #5
0
 /**
  * @depends testFixtures1
  */
 public function testPredicateArg(WAMService $wam)
 {
     $solve = $wam->runQuery("equal(molecule(carbon, oxygen), molecule(carbon, X)).");
     $this->checkOneValueSuccess($solve, 'X', 'oxygen', false);
 }
コード例 #6
0
ファイル: WAMHanoiTest.php プロジェクト: trismegiste/prolog
 /**
  * @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]);
 }