use of org.w3._2005.atom in project packages-jpl by SWI-Prolog.
the class TestOLD method test10q.
private static void test10q() {
System.err.println("test10q:");
System.err.println((new Compound("Bad Name", new Term[] { new Atom("3 3") })).toString());
System.err.println();
}
use of org.w3._2005.atom in project packages-jpl by SWI-Prolog.
the class TestJUnit method testAtomIdentity.
public void testAtomIdentity() {
// how could this fail?!
String name = "fred";
Atom a1 = new Atom(name);
Atom a2 = new Atom(name);
assertNotSame("two Atoms created with the same name are not identical", a1, a2);
}
use of org.w3._2005.atom in project packages-jpl by SWI-Prolog.
the class TestJUnit method testStringXput2.
public void testStringXput2() {
String s1 = "\u0000\u007F\u0080\u00FF";
String s2 = "\u0100\u7FFF\u8000\uFFFF";
// concatenate in Java
String s = s1 + s2;
// concatenate
Term a = Query.oneSolution("string_concat(?,?,S)", new Term[] { new Atom(s1), new Atom(s2) }).get("S");
// in
// Prolog
assertEquals(s, a.name());
assertEquals("string", a.atomType());
}
use of org.w3._2005.atom in project packages-jpl by SWI-Prolog.
the class TestJUnit method testJRef5.
public void testJRef5() {
String token = "foobar345";
Term a = Query.oneSolution("jpl_new('java.lang.StringBuffer',[?],A)", new Term[] { new Atom(token) }).get("A");
assertTrue(((java.lang.StringBuffer) (a.jrefToObject())).toString().equals(token));
}
use of org.w3._2005.atom 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");
}
Aggregations