use of org.jpl7.Atom in project packages-jpl by SWI-Prolog.
the class TestJUnit method testAtomName2.
public void testAtomName2() {
String name = "ha ha";
Atom a = new Atom(name);
assertEquals("an Atom's name is that with which it was created", a.name(), name);
}
use of org.jpl7.Atom in project packages-jpl by SWI-Prolog.
the class TestJUnit method testHasMoreSolutions1.
public void testHasMoreSolutions1() {
StringBuffer sb = new StringBuffer();
Query q = new Query("atom_chars(prolog, Cs), member(C, Cs)");
Map<String, Term> soln;
q.open();
while (q.hasMoreSolutions()) {
soln = q.nextSolution();
sb.append(((Atom) soln.get("C")).name());
}
q.close();
assertEquals("Query#hasMoreSolutions() + Query#nextSolution() work as intended", "prolog", sb.toString());
}
use of org.jpl7.Atom in project packages-jpl by SWI-Prolog.
the class TestJUnit method testAtomName3.
public void testAtomName3() {
String name = "3";
Atom a = new Atom(name);
assertEquals("an Atom's name is that with which it was created", a.name(), name);
}
use of org.jpl7.Atom in project packages-jpl by SWI-Prolog.
the class TestJUnit method suite.
public static junit.framework.Test suite() {
if (syntax.equals("traditional")) {
JPL.setTraditional();
Prolog.set_default_init_args(new String[] { "swipl.dll", "-x", startup, "-f", "none", "-g", "true", "--traditional", "-q", "--home=../..", "--nosignals" });
} else {
Prolog.set_default_init_args(new String[] { "swipl.dll", "-x", startup, "-f", "none", "-g", "true", "-q", "--home=../..", "--nosignals" });
}
assertTrue((new Query("consult", new Term[] { new Atom(test_jpl) })).hasSolution());
assertTrue((new Query("use_module(library(jpl))")).hasSolution());
return new TestSuite(TestJUnit.class);
}
use of org.jpl7.Atom in project packages-jpl by SWI-Prolog.
the class TestJUnit method testStackedQueries1.
public void testStackedQueries1() {
StringBuffer sb = new StringBuffer();
Query q = new Query("atom_chars(prolog, Cs), member(C, Cs)");
Map<String, Term> soln;
q.open();
while ((soln = q.getSolution()) != null) {
Atom a = (Atom) soln.get("C");
if (Query.hasSolution("memberchk(?, [l,o,r])", new Term[] { a })) {
// this
// query
// opens
// and
// closes
// while
// an
// earlier
// query
// is
// still
// open
sb.append(((Atom) soln.get("C")).name());
}
}
// q will have been closed by the final
assertTrue(!q.isOpen());
// getSolution()
assertEquals("rolo", sb.toString());
}
Aggregations