use of org.geotoolkit.sml.xml.v100.Term in project packages-jpl by SWI-Prolog.
the class Init method report_selected_flags.
public static void report_selected_flags() {
System.out.println("REPORTING SELECTED FLAGS: \n");
String prop = "[os_argv, home, executable, version, version_data, traditional, resource_database, toplevel_goal]";
Query q = new Query(String.format("member(X, %s), current_prolog_flag(X, Y)", prop));
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"))));
}
}
use of org.geotoolkit.sml.xml.v100.Term in project packages-jpl by SWI-Prolog.
the class Test method test_5.
static void test_5() {
System.out.print("test 5...");
Variable X = new Variable("X");
Variable Y = new Variable("Y");
Query q5 = new Query("p", new Term[] { X, Y });
Term[] x_target = new Term[] { a, a };
Term[] y_target = new Term[] { a, b };
Map<String, Term>[] solutions = q5.allSolutions();
if (solutions.length != 2) {
System.out.println("p(X, Y) failed:");
System.out.println("\tExpected: 2 solutions");
System.out.println("\tGot: " + solutions.length);
// System.exit(1);
}
for (int i = 0; i < solutions.length; ++i) {
Term x_binding = solutions[i].get("X");
if (!x_binding.equals(x_target[i])) {
System.out.println("p(X, Y) failed:");
System.out.println("\tExpected: " + x_target[i]);
System.out.println("\tGot: " + x_binding);
// System.exit(1);
}
Term y_binding = solutions[i].get("Y");
if (!y_binding.equals(y_target[i])) {
System.out.println("p( X, Y ) failed:");
System.out.println("\tExpected: " + y_target[i]);
System.out.println("\tGot: " + y_binding);
// System.exit(1);
}
}
System.out.println("passed");
}
use of org.geotoolkit.sml.xml.v100.Term in project packages-jpl by SWI-Prolog.
the class Test method test_9.
static void test_9() {
System.out.print("test 9...");
String t9 = "bagof(X-Y, p(X,Y), XYs)";
Map<String, Term>[] solutions = Query.allSolutions(t9);
if (solutions.length != 1) {
System.out.println(t9 + " failed:");
System.out.println("\tExpected: 1 solution");
System.out.println("\tGot: " + solutions.length);
// System.exit(1);
}
Term term = solutions[0].get("XYs");
if (!term.isListPair()) {
System.out.println(t9 + " failed:");
System.out.println("\tExpected: XYs to be a List");
System.out.println("\tGot: " + term);
// System.exit(1);
}
if (!term.equals(test_9_solution)) {
System.out.println(t9 + " failed:");
System.out.println("\tExpected: " + test_9_solution);
System.out.println("\tGot: " + term);
// System.exit(1);
}
System.out.println("passed");
}
use of org.geotoolkit.sml.xml.v100.Term in project packages-jpl by SWI-Prolog.
the class Test method test_11.
static void test_11() {
System.out.print("test 11...");
Term tuple = new Compound("t", new Term[] { new Atom("a"), new Atom("b"), new Atom("c"), new Atom("d"), new Atom("e") });
try {
Variable X = new Variable("X");
Query q11 = new Query("tuple", new Term[] { X });
Term result = q11.oneSolution().get("X");
if (result == null || !result.equals(tuple)) {
System.out.println("failed:");
System.out.println("\tresult: " + result);
System.out.println("\ttuple: " + tuple);
// System.exit(1);
}
if (result.arg(1) == null || !result.arg(1).equals(new Atom("a"))) {
System.out.println("failed:");
System.out.println("\tresult.arg(1): " + result.arg(1));
// System.exit(1);
}
if (result.arg(2) == null || !result.arg(2).equals(new Atom("b"))) {
System.out.println("failed:");
System.out.println("\tresult.arg(2): " + result.arg(2));
// System.exit(1);
}
if (result.arg(5) == null || !result.arg(5).equals(new Atom("e"))) {
System.out.println("failed:");
System.out.println("\tresult.arg(5): " + result.arg(5));
// System.exit(1);
}
// arg0(6) throws an exception, as I'd expect it to...
// if ( ((Compound)result).arg( 7 ) != null ){
// System.out.println( "failed:" );
// System.out.println( "\t((Compound)result).arg( 7 ): " + ((Compound)result).arg( 7 ) );
// System.out.println( "\tshould be null" );
// System.exit( 1 );
// }
} catch (PrologException e) {
System.out.println("failed");
e.printStackTrace();
// System.exit(1);
}
System.out.println("passed");
}
use of org.geotoolkit.sml.xml.v100.Term in project packages-jpl by SWI-Prolog.
the class Test method test_6.
static void test_6() {
System.out.print("test 6...");
Variable X = new Variable("X");
Query q6 = new Query("p", new Term[] { X, X });
Term[] x_target = new Term[] { a };
Map<String, Term>[] solutions = q6.allSolutions();
if (solutions.length != 1) {
System.out.println("p(X, X) failed:");
System.out.println("\tExpected: 1 solution");
System.out.println("\tGot: " + solutions.length);
// System.exit(1);
}
for (int i = 0; i < solutions.length; ++i) {
Object x_binding = solutions[i].get("X");
if (!x_binding.equals(x_target[i])) {
System.out.println("p(X, X) failed:");
System.out.println("\tExpected: " + x_target[i]);
System.out.println("\tGot: " + x_binding);
// System.exit(1);
}
}
System.out.println("passed");
}
Aggregations