use of org.jpl7.Atom in project packages-jpl by SWI-Prolog.
the class TestJUnit method testHasMoreElements1.
@SuppressWarnings("unchecked")
public void testHasMoreElements1() {
StringBuffer sb = new StringBuffer();
Query q = new Query("atom_chars(prolog, Cs), member(C, Cs)");
Map<String, Term> soln;
q.open();
while (q.hasMoreElements()) {
soln = (Map<String, Term>) q.nextElement();
sb.append(((Atom) soln.get("C")).name());
}
q.close();
assertEquals("Query#hasMoreElements() + Query#nextElement() work as intended", "prolog", sb.toString());
}
use of org.jpl7.Atom in project packages-jpl by SWI-Prolog.
the class TestJUnit method testVariableBinding1.
public void testVariableBinding1() {
Term lhs = new Compound("p", new Term[] { new Variable("X"), new Variable("Y") });
Term rhs = new Compound("p", new Term[] { new Atom("a"), new Atom("b") });
Term goal = new Compound("=", new Term[] { lhs, rhs });
Map<String, Term> soln = new Query(goal).oneSolution();
assertTrue("two Variables with different names can bind to distinct atoms", soln != null && (soln.get("X")).name().equals("a") && (soln.get("Y")).name().equals("b"));
}
Aggregations