Description
Jexl attempts to narrow arguments when solving function names; unfortunately,
this may cause issues when the function is a script and the argument type is expected to remain untouched.
The map key in the following code is an Integer; by calling the function fn01, the interpreter fails to find a method and retries after 'narrowing' the argument which becomes a Byte. The Byte is not equal to the Integer map key with the same value; the test fails.
@Test public void test136() throws Exception { JexlEngine jexl = new Engine(); JexlContext jc = new MapContext(); JexlScript script; JexlExpression expr; Object result; script = jexl.createScript("var x = $TAB[idx]; return x;", "idx"); jc.set("fn01", script); script = jexl.createScript("$TAB = { 1:11, 2:22, 3:33}; IDX=2;"); script.execute(jc); expr = jexl.createExpression("fn01(IDX)"); result = expr.evaluate(jc); assertEquals("EXPR01 result", 22, result); }