Search in sources :

Example 61 with Term

use of org.jpl7.Term in project packages-jpl by SWI-Prolog.

the class TestJUnit method testUtilListToTermArray1.

public void testUtilListToTermArray1() {
    String goal = "T = [a,b,c]";
    Term list = Query.oneSolution(goal).get("T");
    Term[] array = Util.listToTermArray(list);
    assertTrue(array[2].isAtom() && array[2].name().equals("c"));
}
Also used : Term(org.jpl7.Term)

Example 62 with Term

use of org.jpl7.Term in project packages-jpl by SWI-Prolog.

the class TestJUnit method testIsJTrue3.

public void testIsJTrue3() {
    Term t = Query.oneSolution("X = _").get("X");
    assertFalse("_ . isJTrue() fails", t.isJTrue());
}
Also used : Term(org.jpl7.Term)

Example 63 with Term

use of org.jpl7.Term in project packages-jpl by SWI-Prolog.

the class TestJUnit method testWouter1.

public void testWouter1() {
    // Wouter says this fails under OS X Mavericks
    // 10.9 x86-64
    // too big for an int
    long n = 7381783232223l;
    Compound term = new Compound("is", new Term[] { new Variable("X"), new org.jpl7.Integer(n) });
    Map<String, Term>[] solutions = new Query(term).allSolutions();
    assertEquals(1, solutions.length);
    Map<String, Term> solution = solutions[0];
    assertTrue(solution.containsKey("X"));
    Object result = solution.get("X");
    assertTrue(result instanceof org.jpl7.Integer);
    assertEquals(n, ((org.jpl7.Integer) result).longValue());
}
Also used : Variable(org.jpl7.Variable) Query(org.jpl7.Query) Integer(org.jpl7.Integer) Compound(org.jpl7.Compound) Term(org.jpl7.Term) Map(java.util.Map)

Example 64 with Term

use of org.jpl7.Term in project packages-jpl by SWI-Prolog.

the class TestJUnit method testIsJTrue1.

public void testIsJTrue1() {
    Term t = Query.oneSolution("X = @(true)").get("X");
    assertTrue("@(true) . isJTrue() succeeds", t.isJTrue());
}
Also used : Term(org.jpl7.Term)

Example 65 with Term

use of org.jpl7.Term in project packages-jpl by SWI-Prolog.

the class TestJUnit method testIsJTrue4.

public void testIsJTrue4() {
    Term t = Query.oneSolution("X = @(false)").get("X");
    assertFalse("@(false) . isJTrue() fails", t.isJTrue());
}
Also used : Term(org.jpl7.Term)

Aggregations

Term (org.jpl7.Term)62 Query (org.jpl7.Query)42 Variable (org.jpl7.Variable)24 Atom (org.jpl7.Atom)21 Compound (org.jpl7.Compound)21 Map (java.util.Map)12 BigInteger (java.math.BigInteger)6 Integer (org.jpl7.Integer)6 org.jpl7.fli.term_t (org.jpl7.fli.term_t)4 Term (org.apache.cassandra.cql3.Term)3 MarshalException (org.apache.cassandra.serializers.MarshalException)3 PrologException (org.jpl7.PrologException)3 JPLException (org.jpl7.JPLException)2 IntHolder (org.jpl7.fli.IntHolder)2 URL (java.net.URL)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 TestSuite (junit.framework.TestSuite)1 DoubleHolder (org.jpl7.fli.DoubleHolder)1 Int64Holder (org.jpl7.fli.Int64Holder)1 ObjectHolder (org.jpl7.fli.ObjectHolder)1