Search in sources :

Example 16 with Term

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

the class TestJUnit method testJRef4.

public void testJRef4() {
    Term jrefSB = Query.oneSolution("jpl_new('java.lang.StringBuffer',['abc'],SB)").get("SB");
    assertTrue(jrefSB.isJRef() && ((StringBuffer) jrefSB.jrefToObject()).toString().equals("abc"));
}
Also used : Term(org.jpl7.Term)

Example 17 with Term

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

the class TestJUnit method testIsJNull5.

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

Example 18 with Term

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

the class TestJUnit method testTextToTerm1.

public void testTextToTerm1() {
    String text = "fred(B,p(A))";
    Term t = Util.textToTerm(text);
    assertTrue("Util.textToTerm() converts \"fred(B,p(A))\" to a corresponding Term", t.hasFunctor("fred", 2) && t.arg(1).isVariable() && t.arg(1).name().equals("B") && t.arg(2).hasFunctor("p", 1) && t.arg(2).arg(1).isVariable() && t.arg(2).arg(1).name().equals("A"));
}
Also used : Term(org.jpl7.Term)

Example 19 with Term

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

the class TestJUnit method testBigInteger1.

public void testBigInteger1() {
    BigInteger a = new BigInteger(Long.toString(51L));
    // 51**51, too big for a long
    BigInteger b = a.pow(51);
    Term x = Query.oneSolution("X is 51**51").get("X");
    assertTrue("X is an org.jpl7.Integer", x.isInteger());
    // System.out.println("X.bigValue() = " + x.bigValue().toString());
    // System.out.println("b.bigValue() = " + b.toString());
    assertTrue("X is a big integer", x.isBigInteger());
    assertTrue("X's big value is 51**51", x.bigValue().equals(b));
}
Also used : BigInteger(java.math.BigInteger) Term(org.jpl7.Term)

Example 20 with Term

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

the class TestJUnit method testIsJNull2.

public void testIsJNull2() {
    Term t = Query.oneSolution("X = @(3)").get("X");
    assertFalse("@(3) . 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