Search in sources :

Example 81 with Query

use of org.molgenis.emx2.Query in project packages-jpl by SWI-Prolog.

the class TestJUnit method testDontTellMeMode1.

public void testDontTellMeMode1() {
    final Query q = new Query("setof(_M,current_module(_M),_Ms),length(_Ms,N)");
    JPL.setDTMMode(true);
    assertTrue("in dont-tell-me mode, setof(_M,current_module(_M),_Ms),length(_Ms,N) returns binding for just one variable", q.oneSolution().keySet().size() == 1);
}
Also used : Query(org.jpl7.Query)

Example 82 with Query

use of org.molgenis.emx2.Query 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 83 with Query

use of org.molgenis.emx2.Query 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 84 with Query

use of org.molgenis.emx2.Query in project packages-jpl by SWI-Prolog.

the class TestJUnit method testVariableBinding3.

public void testVariableBinding3() {
    Variable X = new Variable("X");
    Term lhs = new Compound("p", new Term[] { X, X });
    Term rhs = new Compound("p", new Term[] { new Atom("a"), new Atom("b") });
    Term goal = new Compound("=", new Term[] { lhs, rhs });
    assertFalse("two references to the same (named) Variable cannot unify with differing atoms", new Query(goal).hasSolution());
}
Also used : Variable(org.jpl7.Variable) Query(org.jpl7.Query) Compound(org.jpl7.Compound) Term(org.jpl7.Term) Atom(org.jpl7.Atom)

Example 85 with Query

use of org.molgenis.emx2.Query in project packages-jpl by SWI-Prolog.

the class TestJUnit method testArrayToList1.

public void testArrayToList1() {
    Term l2 = Util.termArrayToList(new Term[] { new Atom("a"), new Atom("b"), new Atom("c"), new Atom("d"), new Atom("e") });
    Query q9 = new Query(new Compound("append", new Term[] { new Variable("Xs"), new Variable("Ys"), l2 }));
    assertTrue("append(Xs,Ys,[a,b,c,d,e]) has 6 solutions", q9.allSolutions().length == 6);
}
Also used : Variable(org.jpl7.Variable) Query(org.jpl7.Query) Compound(org.jpl7.Compound) Term(org.jpl7.Term) Atom(org.jpl7.Atom)

Aggregations

Query (org.jpl7.Query)88 Term (org.jpl7.Term)52 Variable (org.jpl7.Variable)32 Query (org.hypertrace.entity.data.service.v1.Query)31 Map (java.util.Map)28 Test (org.junit.jupiter.api.Test)23 Atom (org.jpl7.Atom)21 Compound (org.jpl7.Compound)18 Test (org.junit.Test)18 Filter (org.hypertrace.core.documentstore.Filter)16 Query (com.google.datastore.v1.Query)14 AttributeFilter (org.hypertrace.entity.data.service.v1.AttributeFilter)14 GqlQuery (com.google.datastore.v1.GqlQuery)7 ArrayList (java.util.ArrayList)7 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)6 Entity (org.hypertrace.entity.data.service.v1.Entity)6 Integer (org.jpl7.Integer)6 Query (org.molgenis.emx2.Query)6 IOException (java.io.IOException)5 Collections (java.util.Collections)5