Exemplo n.º 1
0
  @Test
  public void parseRule() {
    Rule r = DlgpParser.parseRule("p(X,Y) :- q(X,Z).");

    Atom body = r.getBody().iterator().next();
    Assert.assertEquals(Term.Type.VARIABLE, body.getTerm(0).getType());
    Assert.assertEquals(Term.Type.VARIABLE, body.getTerm(1).getType());

    Atom head = r.getHead().iterator().next();
    Assert.assertEquals(Term.Type.VARIABLE, head.getTerm(0).getType());
    Assert.assertEquals(Term.Type.VARIABLE, head.getTerm(1).getType());
  }
Exemplo n.º 2
0
  @Test
  public void parseNegativeConstraint() {
    DefaultNegativeConstraint r = DlgpParser.parseNegativeConstraint("[N1]!:-p(X,Y), q(X,Y).");

    Iterator<Atom> it = r.getBody().iterator();
    Atom body = it.next();
    Assert.assertEquals(Term.Type.VARIABLE, body.getTerm(0).getType());
    Assert.assertEquals(Term.Type.VARIABLE, body.getTerm(1).getType());

    body = it.next();
    Assert.assertEquals(Term.Type.VARIABLE, body.getTerm(0).getType());
    Assert.assertEquals(Term.Type.VARIABLE, body.getTerm(1).getType());

    Assert.assertEquals("N1", r.getLabel());
  }
Exemplo n.º 3
0
 @Test
 public void parseAtom() {
   Atom a = DlgpParser.parseAtom("p(a, X).");
   Assert.assertEquals(Term.Type.VARIABLE, a.getTerm(1).getType());
 }