Search in sources :

Example 21 with org.w3._2005.atom

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();
}
Also used : Compound(org.jpl7.Compound) Term(org.jpl7.Term) Atom(org.jpl7.Atom)

Example 22 with org.w3._2005.atom

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);
}
Also used : Atom(org.jpl7.Atom)

Example 23 with org.w3._2005.atom

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());
}
Also used : Term(org.jpl7.Term) Atom(org.jpl7.Atom)

Example 24 with org.w3._2005.atom

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));
}
Also used : Term(org.jpl7.Term) Atom(org.jpl7.Atom)

Example 25 with org.w3._2005.atom

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");
}
Also used : Variable(org.jpl7.Variable) Query(org.jpl7.Query) PrologException(org.jpl7.PrologException) Compound(org.jpl7.Compound) Term(org.jpl7.Term) Atom(org.jpl7.Atom)

Aggregations

Atom (org.jpl7.Atom)38 Term (org.jpl7.Term)23 Query (org.jpl7.Query)21 Variable (org.jpl7.Variable)15 Compound (org.jpl7.Compound)14 URL (java.net.URL)6 Test (org.junit.Test)6 ActionVar (org.w3._2007.rif.Do.ActionVar)5 DomBasedUnitTest (com.onespatial.jrc.tns.oml_to_rif.fixture.DomBasedUnitTest)4 Document (org.w3._2007.rif.Document)4 Var (org.w3._2007.rif.Var)4 Map (java.util.Map)3 PrologException (org.jpl7.PrologException)3 Const (org.w3._2007.rif.Const)3 MapItem (org.apache.sis.portrayal.MapItem)2 WhereType (org.geotoolkit.georss.xml.v100.WhereType)2 DirectPositionType (org.geotoolkit.gml.xml.v311.DirectPositionType)2 EnvelopeType (org.geotoolkit.gml.xml.v311.EnvelopeType)2 Assert (org.w3._2007.rif.Assert)2 Instance (org.w3._2007.rif.Instance)2