Search in sources :

Example 86 with Query

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

the class TestJUnit method testDontTellMeMode2.

public void testDontTellMeMode2() {
    final Query q = new Query("setof(_M,current_module(_M),_Ms),length(_Ms,N)");
    JPL.setDTMMode(false);
    assertTrue("not in dont-tell-me mode, setof(_M,current_module(_M),_Ms),length(_Ms,N) returns binding for three variables", q.oneSolution().keySet().size() == 3);
}
Also used : Query(org.jpl7.Query)

Example 87 with Query

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

the class TestJUnit method testOpenGetClose2.

public void testOpenGetClose2() {
    // we're not going to open this...
    Query q = new Query("dummy");
    try {
        // should throw exception (query not open)
        q.getSolution();
        // shouldn't get
        fail("getSolution() succeeds on unopened Query");
    // to here
    } catch (JPLException e) {
        // expected exception class
        if (e.getMessage().endsWith("Query is not open")) {
        // OK: an appropriate exception was thrown
        } else {
            fail("jpl.Query#getSolution() threw wrong JPLException: " + e);
        }
    } catch (Exception e) {
        fail("jpl.Query#getSolution() threw wrong exception class: " + e);
    }
}
Also used : Query(org.jpl7.Query) JPLException(org.jpl7.JPLException) PrologException(org.jpl7.PrologException) JPLException(org.jpl7.JPLException)

Example 88 with Query

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

the class TestJUnit method testVariableBinding5.

public void testVariableBinding5() {
    Variable Anon = new Variable("_");
    Term lhs = new Compound("p", new Term[] { Anon, Anon });
    Term rhs = new Compound("p", new Term[] { new Atom("a"), new Atom("b") });
    Term goal = new Compound("=", new Term[] { lhs, rhs });
    assertTrue("two references to an anonymous Variable can 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 89 with Query

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

the class TestJUnit method testVariableBinding4.

public void testVariableBinding4() {
    Term lhs = new Compound("p", new Term[] { new Variable("_"), new Variable("_") });
    Term rhs = new Compound("p", new Term[] { new Atom("a"), new Atom("b") });
    Term goal = new Compound("=", new Term[] { lhs, rhs });
    assertTrue("two distinct anonymous Variables can unify with distinct 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 90 with Query

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

the class TestJUnit method testLength1.

public void testLength1() {
    Query q5 = new Query(new Compound("length", new Term[] { new Variable("Zs"), new org.jpl7.Integer(2) }));
    Term zs = q5.oneSolution().get("Zs");
    assertTrue("length(Zs,2) binds Zs to a list of two distinct variables " + zs.toString(), zs.isListPair() && zs.arg(1).isVariable() && zs.arg(2).isListPair() && zs.arg(2).arg(1).isVariable() && zs.arg(2).arg(2).isListNil() && !zs.arg(1).name().equals(zs.arg(2).arg(1).name()));
}
Also used : Integer(org.jpl7.Integer) BigInteger(java.math.BigInteger) Variable(org.jpl7.Variable) Query(org.jpl7.Query) Compound(org.jpl7.Compound) Term(org.jpl7.Term)

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