Search in sources :

Example 1 with FunctionEnvBase

use of org.apache.jena.sparql.function.FunctionEnvBase in project jena by apache.

the class TestFunctions2 method test.

private static void test(String string, String result) {
    Expr expr = ExprUtils.parse(string, pmap);
    NodeValue nv = expr.eval(null, new FunctionEnvBase());
    Node r = NodeFactoryExtra.parseNode(result);
    NodeValue nvr = NodeValue.makeNode(r);
    assertTrue("Not same value: Expected: " + nvr + " : Actual = " + nv, NodeValue.sameAs(nvr, nv));
    // test result must be lexical form exact. 
    assertEquals(r, nv.asNode());
}
Also used : NodeValue(org.apache.jena.sparql.expr.NodeValue) Expr(org.apache.jena.sparql.expr.Expr) Node(org.apache.jena.graph.Node) FunctionEnvBase(org.apache.jena.sparql.function.FunctionEnvBase)

Example 2 with FunctionEnvBase

use of org.apache.jena.sparql.function.FunctionEnvBase in project jena by apache.

the class TestExpressions method testEval.

private static void testEval(String string) {
    Expr expr = parse(string);
    NodeValue v = expr.eval(BindingFactory.binding(), new FunctionEnvBase());
}
Also used : NodeValue(org.apache.jena.sparql.expr.NodeValue) Expr(org.apache.jena.sparql.expr.Expr) FunctionEnvBase(org.apache.jena.sparql.function.FunctionEnvBase)

Example 3 with FunctionEnvBase

use of org.apache.jena.sparql.function.FunctionEnvBase in project jena by apache.

the class TestExpressions method testNumeric.

private static void testNumeric(String string, BigInteger integer) {
    Expr expr = parse(string);
    NodeValue v = expr.eval(BindingFactory.binding(), new FunctionEnvBase());
    assertTrue(v.isInteger());
    assertEquals(integer, v.getInteger());
}
Also used : NodeValue(org.apache.jena.sparql.expr.NodeValue) Expr(org.apache.jena.sparql.expr.Expr) FunctionEnvBase(org.apache.jena.sparql.function.FunctionEnvBase)

Example 4 with FunctionEnvBase

use of org.apache.jena.sparql.function.FunctionEnvBase in project jena by apache.

the class TestExpressions method testNumeric.

private static void testNumeric(String string, BigDecimal decimal) {
    Expr expr = parse(string);
    NodeValue v = expr.eval(BindingFactory.binding(), new FunctionEnvBase());
    assertTrue(v.isDecimal());
    assertEquals(decimal, v.getDecimal());
}
Also used : NodeValue(org.apache.jena.sparql.expr.NodeValue) Expr(org.apache.jena.sparql.expr.Expr) FunctionEnvBase(org.apache.jena.sparql.function.FunctionEnvBase)

Example 5 with FunctionEnvBase

use of org.apache.jena.sparql.function.FunctionEnvBase in project jena by apache.

the class TestExpressions method testURI.

private static void testURI(String string, String uri) {
    Expr expr = parse(string);
    NodeValue v = expr.eval(env, new FunctionEnvBase());
    assertTrue(v.isIRI());
    assertEquals(uri, v.getNode().getURI());
}
Also used : NodeValue(org.apache.jena.sparql.expr.NodeValue) Expr(org.apache.jena.sparql.expr.Expr) FunctionEnvBase(org.apache.jena.sparql.function.FunctionEnvBase)

Aggregations

FunctionEnvBase (org.apache.jena.sparql.function.FunctionEnvBase)13 Expr (org.apache.jena.sparql.expr.Expr)9 NodeValue (org.apache.jena.sparql.expr.NodeValue)9 Node (org.apache.jena.graph.Node)1