context.setVariable("v0", new ObjectValueExpression(0, long.class));
context.setVariable("v1", new ObjectValueExpression(1, long.class));
}
public void testBindFunctions() throws Exception {
Bindings bindings = null;
bindings = parse("${ns:f0()}").bind(context.getFunctionMapper(), null);
assertSame(context.getFunctionMapper().resolveFunction("ns", "f0"), bindings.getFunction(0));
try { bindings.getFunction(1); fail(); } catch (Exception e) {}
bindings = parse("${ns:f1(1)}").bind(context.getFunctionMapper(), null);
assertSame(context.getFunctionMapper().resolveFunction("ns", "f1"), bindings.getFunction(0));
try { bindings.getFunction(1); fail(); } catch (Exception e) {}
bindings = parse("${ns:f0()+ns:f1(1)}").bind(context.getFunctionMapper(), null);
assertSame(context.getFunctionMapper().resolveFunction("ns", "f0"), bindings.getFunction(0));
assertSame(context.getFunctionMapper().resolveFunction("ns", "f1"), bindings.getFunction(1));
try { bindings.getFunction(2); fail(); } catch (Exception e) {}
// the same for default namespace functions g0(), g1()
bindings = parse("${g0()}").bind(context.getFunctionMapper(), null);
assertSame(context.getFunctionMapper().resolveFunction("", "g0"), bindings.getFunction(0));
try { bindings.getFunction(1); fail(); } catch (Exception e) {}
bindings = parse("${g1(1)}").bind(context.getFunctionMapper(), null);
assertSame(context.getFunctionMapper().resolveFunction("", "g1"), bindings.getFunction(0));
try { bindings.getFunction(1); fail(); } catch (Exception e) {}
bindings = parse("${g0()+g1(1)}").bind(context.getFunctionMapper(), null);
assertSame(context.getFunctionMapper().resolveFunction("", "g0"), bindings.getFunction(0));
assertSame(context.getFunctionMapper().resolveFunction("", "g1"), bindings.getFunction(1));
try { bindings.getFunction(2); fail(); } catch (Exception e) {}
try { parse("${foo()}").bind(context.getFunctionMapper(), null); fail(); } catch (Exception e) {}
try { parse("${g1()}").bind(context.getFunctionMapper(), null); fail(); } catch (Exception e) {}
try { parse("${g1(1,2)}").bind(context.getFunctionMapper(), null); fail(); } catch (Exception e) {}
}