use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Integer in project packages-jpl by SWI-Prolog.
the class Tests method testWouter1.
@Test
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 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 Integer);
assertEquals(n, ((Integer) result).longValue());
}
use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Integer in project packages-jpl by SWI-Prolog.
the class Test_Integer method testBigInteger2.
@Test
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());
assertEquals("X's value is as expected", x.bigValue(), b);
}
use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Integer in project packages-jpl by SWI-Prolog.
the class Test_Integer method testIntegerFromByte1.
// /////////////////////////////////////////////////////////////////////////////
// SUPPORTING CODE
// /////////////////////////////////////////////////////////////////////////////
// /////////////////////////////////////////////////////////////////////////////
// TESTS
// /////////////////////////////////////////////////////////////////////////////
@Test
public void testIntegerFromByte1() {
// -128..127
byte b = (byte) 127;
Integer i = new Integer(b);
assertEquals(i.intValue(), b);
}
use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Integer in project packages-jpl by SWI-Prolog.
the class Test_JRef method testJRef2.
@Test
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);
}
use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Integer in project packages-jpl by SWI-Prolog.
the class Test_JRef method testJRef1.
// /////////////////////////////////////////////////////////////////////////////
// SUPPORTING CODE
// /////////////////////////////////////////////////////////////////////////////
// /////////////////////////////////////////////////////////////////////////////
// TESTS
// /////////////////////////////////////////////////////////////////////////////
@Test
public void testJRef1() {
int i = 76543;
Integer I = new Integer(i);
Query q = new Query("jpl_call(?,intValue,[],I2)", new Term[] { JPL.newJRef(I) });
Term I2 = q.oneSolution().get("I2");
assertTrue(I2.isInteger() && I2.intValue() == i);
}
Aggregations