Search in sources :

Example 56 with Term

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

the class TestJUnit method testCompoundZeroArity1.

public void testCompoundZeroArity1() {
    Term t = new Compound("foo", new Term[] {});
    assertTrue(t.isCompound());
    assertFalse(t.isAtom());
    assertTrue(t.name().equals("foo"));
    assertTrue(t.arity() == 0);
}
Also used : Compound(org.jpl7.Compound) Term(org.jpl7.Term)

Example 57 with Term

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

the class TestJUnit method testCompoundZeroArity2.

public void testCompoundZeroArity2() {
    Term t = Query.oneSolution("T = foo()").get("T");
    // System.out.println("type = " + t.typeName());
    assertTrue(t.name().equals("foo"));
    assertTrue(t.arity() == 0);
}
Also used : Term(org.jpl7.Term)

Example 58 with Term

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

the class TestJUnit method testBigInteger2.

public void testBigInteger2() {
    BigInteger b = new BigInteger("12345678901234567890123456789");
    // too big for a long
    Term i = new Integer(b);
    Term g = new Compound("is", new Term[] { new Variable("X"), i });
    Term x = Query.oneSolution(g).get("X");
    assertTrue("X is an org.jpl7.Integer", x.isInteger());
    assertTrue("X is a big org.jpl7.Integer", x.isBigInteger());
    assertTrue("X's value is as expected", x.bigValue().equals(b));
}
Also used : Integer(org.jpl7.Integer) BigInteger(java.math.BigInteger) Variable(org.jpl7.Variable) BigInteger(java.math.BigInteger) Compound(org.jpl7.Compound) Term(org.jpl7.Term)

Example 59 with Term

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

the class TestJUnit method testJRef2.

public void testJRef2() {
    int i = 76543;
    Integer I = new Integer(i);
    Query q = new Query("jpl_call(?,intValue,[],I2)", JPL.newJRef(I));
    Term I2 = q.oneSolution().get("I2");
    assertTrue(I2.isInteger() && I2.intValue() == i);
}
Also used : Integer(org.jpl7.Integer) BigInteger(java.math.BigInteger) Query(org.jpl7.Query) Term(org.jpl7.Term)

Example 60 with Term

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

the class TestJUnit method testIsJNull3.

public void testIsJNull3() {
    Term t = Query.oneSolution("X = _").get("X");
    assertFalse("_ . isJNull() fails", t.isJNull());
}
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