Search in sources :

Example 91 with Expr

use of org.apache.jena.sparql.expr.Expr in project jena by apache.

the class TestExprLib method testSafeEquality.

private static void testSafeEquality(String string, boolean b, boolean graphString, boolean graphNumber) {
    Expr expr = ExprUtils.parse(string);
    Assert.assertEquals(string, b, ExprLib.isAssignmentSafeEquality(expr, graphString, graphNumber));
}
Also used : Expr(org.apache.jena.sparql.expr.Expr)

Example 92 with Expr

use of org.apache.jena.sparql.expr.Expr in project jena by apache.

the class TestExpressions method testVar.

private static void testVar(String string, String rightVarName) {
    Expr expr = parse(string);
    assertTrue("Not a NodeVar: " + expr, expr.isVariable());
    ExprVar v = (ExprVar) expr;
    assertEquals("Different variable names", rightVarName, v.getVarName());
}
Also used : ExprVar(org.apache.jena.sparql.expr.ExprVar) Expr(org.apache.jena.sparql.expr.Expr)

Example 93 with Expr

use of org.apache.jena.sparql.expr.Expr in project jena by apache.

the class TestExpressions2 method eval.

// It's easier to write tests that simply are expected to return true/false 
/*package*/
static void eval(String string, boolean result) {
    Expr expr = ExprUtils.parse(string);
    NodeValue nv = expr.eval(null, FunctionEnvBase.createTest());
    boolean b = XSDFuncOp.booleanEffectiveValue(nv);
    assertEquals(string, result, b);
}
Also used : NodeValue(org.apache.jena.sparql.expr.NodeValue) Expr(org.apache.jena.sparql.expr.Expr)

Example 94 with Expr

use of org.apache.jena.sparql.expr.Expr in project jena by apache.

the class TestSSE_Builder method testBuildExpr_01.

@Test
public void testBuildExpr_01() {
    Expr e = SSE.parseExpr("(sameTerm (?x) (?y))");
    assertTrue(e instanceof E_SameTerm);
}
Also used : Expr(org.apache.jena.sparql.expr.Expr) E_SameTerm(org.apache.jena.sparql.expr.E_SameTerm) Test(org.junit.Test)

Example 95 with Expr

use of org.apache.jena.sparql.expr.Expr in project jena by apache.

the class TestRegex method regexTest.

public void regexTest(String value, String pattern, String flags, boolean expected) {
    Expr s = NodeValue.makeString(value);
    E_Regex r = new E_Regex(s, pattern, flags);
    NodeValue nv = r.eval(BindingFactory.binding(), null);
    boolean b = nv.getBoolean();
    if (b != expected)
        fail(fmtTest(value, pattern, flags) + " ==> " + b + " expected " + expected);
}
Also used : E_Regex(org.apache.jena.sparql.expr.E_Regex) NodeValue(org.apache.jena.sparql.expr.NodeValue) Expr(org.apache.jena.sparql.expr.Expr)

Aggregations

Expr (org.apache.jena.sparql.expr.Expr)187 Test (org.junit.Test)102 ExprVar (org.apache.jena.sparql.expr.ExprVar)34 Var (org.apache.jena.sparql.core.Var)30 ExprList (org.apache.jena.sparql.expr.ExprList)16 Op (org.apache.jena.sparql.algebra.Op)15 NodeValue (org.apache.jena.sparql.expr.NodeValue)12 ContractTest (org.xenei.junit.contract.ContractTest)11 Query (org.apache.jena.query.Query)10 Node (org.apache.jena.graph.Node)9 E_Random (org.apache.jena.sparql.expr.E_Random)9 ArrayList (java.util.ArrayList)8 VarExprList (org.apache.jena.sparql.core.VarExprList)8 Triple (org.apache.jena.graph.Triple)6 SortCondition (org.apache.jena.query.SortCondition)6 E_Regex (org.apache.jena.sparql.expr.E_Regex)6 E_LessThan (org.apache.jena.sparql.expr.E_LessThan)5 LibTestExpr (org.apache.jena.sparql.expr.LibTestExpr)5 OpBGP (org.apache.jena.sparql.algebra.op.OpBGP)4 BasicPattern (org.apache.jena.sparql.core.BasicPattern)4