use of org.geotoolkit.sml.xml.v100.Term in project packages-jpl by SWI-Prolog.
the class Test method test_7.
static void test_7() {
System.out.print("test 7...");
String t7 = "r(f(X,X), Y)";
Variable vX = new Variable("X");
Variable vY = new Variable("Y");
Query q7 = new Query("r", new Term[] { new Compound("f", new Term[] { vX, vX }), vY });
Map<String, Term>[] solutions = q7.allSolutions();
if (solutions.length != 2) {
System.out.println(t7 + " failed:");
System.out.println("\tExpected: 2 solutions");
System.out.println("\tGot: " + solutions.length);
// System.exit(1);
}
Term X = solutions[0].get("X");
Term Y = solutions[0].get("Y");
if (X != Y) {
System.out.println(t7 + " failed:");
System.out.println(Util.subsToString(solutions[0]));
System.out.println("\tThe variables to which X and Y are bound in the first solution should be identical.");
// System.exit(1);
}
X = solutions[1].get("X");
Y = solutions[1].get("Y");
if (X == Y) {
System.out.println(t7 + " failed:");
System.out.println(Util.subsToString(solutions[1]));
System.out.println("\tThe variables to which X and Y are bound in the second solution should be distinct.");
// System.exit(1);
}
if (X.equals(Y)) {
System.out.println(t7 + " failed:");
System.out.println(Util.subsToString(solutions[1]));
System.out.println("\tThe variables to which X and Y are bound in the second solution should not be \"equal\".");
// System.exit(1);
}
System.out.println("passed");
}
use of org.geotoolkit.sml.xml.v100.Term in project packages-jpl by SWI-Prolog.
the class PrologMT method run.
/**
* Run a Java thread with a Prolog engine attached during the life time
* of the thread. The thread must call Prolog.destroy_engine() before
* terminating. Eventually we would like to make that optional, but I
* have not yet found a way to get notified in time. We can get a
* notification using the destruction function of a pthread local key,
* but that is called after the thread died and we can no longer do
* Prolog's thread cleanup magic. Currently we use this to print
* a message telling you forgot to call Prolog.destroy_engine()
*/
public void run() {
Map<String, Term> solution;
Prolog.create_engine();
// new Query("welcome").hasSolution();
// new Query("time(rtest_chats("+chats+"))").hasSolution();
new Query("rtest_chats(" + chats + ")").hasSolution();
Prolog.destroy_engine();
// System.out.println("Done");
}
use of org.geotoolkit.sml.xml.v100.Term in project packages-jpl by SWI-Prolog.
the class PrologMT method pid.
public static int pid() {
Map<String, Term> solution;
Query q = new Query("current_prolog_flag(pid, PID)");
solution = q.oneSolution();
return solution.get("PID").intValue();
}
use of org.geotoolkit.sml.xml.v100.Term in project packages-jpl by SWI-Prolog.
the class Test_Report method ReportPrologFlags.
@Test
public void ReportPrologFlags() {
StringBuffer sb = new StringBuffer();
Query q = new Query("current_prolog_flag(X, Y)");
q.open();
while (q.hasMoreSolutions()) {
Map<String, Term> sol = q.nextSolution();
System.out.println(String.format("\t Value of %s: %s", sol.get("X").toString(), sol.get(("Y").toString())));
}
q.close();
}
use of org.geotoolkit.sml.xml.v100.Term in project packages-jpl by SWI-Prolog.
the class Test_String method testStringXput1.
// /////////////////////////////////////////////////////////////////////////////
// SUPPORTING CODE
// /////////////////////////////////////////////////////////////////////////////
// /////////////////////////////////////////////////////////////////////////////
// TESTS
// /////////////////////////////////////////////////////////////////////////////
@Test
public void testStringXput1() {
Term a = Query.oneSolution("string_concat(foo,bar,S)").get("S");
assertEquals("foobar", a.name());
assertEquals("string", a.atomType());
}
Aggregations