Пример #1
0
 private function assertEquivalentSyntax(Syntax $expected, Syntax $actual)
 {
     $n = new Notification();
     $expected->probeEquivalence($actual, $n);
     $this->assertNotificationOk($n);
     $n = new Notification();
     $actual->probeEquivalence($expected, $n);
     $this->assertNotificationOk($n);
 }
Пример #2
0
 public function testProbeEquivalenceSyntaxWithRules()
 {
     $syntax1 = new Syntax();
     $syntax1->title = "foo";
     $syntax1->meta = "bar";
     $syntax2 = new Syntax();
     $syntax2->title = "foo";
     $syntax2->meta = "bar";
     $syntax3 = new Syntax();
     $syntax3->title = "foo";
     $syntax3->meta = "bar";
     $rule1 = new Rule($this->getMock('de\\weltraumschaf\\ebnf\\ast\\Node'));
     $rule1->name = "rule1";
     $syntax1->addChild($rule1);
     $syntax2->addChild($rule1);
     $n = new Notification();
     $syntax1->probeEquivalence($syntax2, $n);
     $this->assertTrue($n->isOk(), $n->report());
     $this->assertEquals("", $n->report());
     $n = new Notification();
     $syntax2->probeEquivalence($syntax1, $n);
     $this->assertTrue($n->isOk(), $n->report());
     $this->assertEquals("", $n->report());
     $rule2 = new Rule($this->getMock('de\\weltraumschaf\\ebnf\\ast\\Node'));
     $rule2->name = "rule2";
     $syntax1->addChild($rule2);
     $error = "Node syntax has different child count than other: 2 != 1!\n";
     $error .= "Other node has not the expected subnode!";
     $n = new Notification();
     $syntax1->probeEquivalence($syntax2, $n);
     $this->assertFalse($n->isOk());
     $this->assertEquals($error, $n->report());
     $error = "Node syntax has different child count than other: 1 != 2!";
     $n = new Notification();
     $syntax2->probeEquivalence($syntax1, $n);
     $this->assertFalse($n->isOk());
     $this->assertEquals($error, $n->report());
     $syntax2->addChild($rule2);
     $n = new Notification();
     $syntax1->probeEquivalence($syntax2, $n);
     $this->assertTrue($n->isOk(), $n->report());
     $this->assertEquals("", $n->report());
     $n = new Notification();
     $syntax2->probeEquivalence($syntax1, $n);
     $this->assertTrue($n->isOk(), $n->report());
     $this->assertEquals("", $n->report());
     $rule3 = new Rule($this->getMock('de\\weltraumschaf\\ebnf\\ast\\Node'));
     $rule3->name = "rule3";
     $syntax3->addChild($rule1);
     $syntax3->addChild($rule3);
     $n = new Notification();
     $syntax1->probeEquivalence($syntax3, $n);
     $this->assertFalse($n->isOk());
     $this->assertEquals("Names of rule differs: 'rule2' != 'rule3'!", $n->report());
 }