public void testFunctionDefAndCall2() { ExpressionCompiler compiler = new ExpressionCompiler("function heyFoo() { return 'Foobar'; };\n" + "return heyFoo() + heyFoo();"); Serializable s = compiler.compile(); Map<String, Function> m = extractAllDeclaredFunctions((CompiledExpression) s); assertTrue(m.containsKey("heyFoo")); OptimizerFactory.setDefaultOptimizer("reflective"); assertEquals("FoobarFoobar", executeExpression(s, new HashMap())); assertEquals("FoobarFoobar", executeExpression(s, new HashMap())); OptimizerFactory.setDefaultOptimizer("dynamic"); }