@Test public void testExecCallsNamedFunctionWithRestOfArguments() throws Exception { final RhsFunctionManager rhsFuncs = new RhsFunctionManager(rhsFuncContext); rhsFuncs.registerHandler(new Plus()); final ExecRhsFunction exec = new ExecRhsFunction(rhsFuncs); final Symbol result = exec.execute(rhsFuncContext, Symbols.asList(syms, "+", 1, 2, 3, 4)); assertEquals(1 + 2 + 3 + 4, result.asInteger().getValue()); }
@Override public Symbol execute(RhsFunctionContext context, List<Symbol> arguments) throws RhsFunctionException { RhsFunctions.checkArgumentCount(this, arguments); final String functionName = arguments.get(0).toString(); if(functionName.equals(getName())) { throw new RhsFunctionException("'exec' RHS function calling itself"); } return rhsFunctions.execute(functionName, arguments.subList(1, arguments.size())); }
ExecRhsFunction extends AbstractRhsFunctionHandler { @Override public Symbol execute(RhsFunctionContext context, List<Symbol> arguments) throws RhsFunctionException { RhsFunctions.checkArgumentCount(this, arguments); final String functionName = arguments.get(0).toString(); if(functionName.equals(getName())) { throw new RhsFunctionException("'exec' RHS function calling itself"); } return rhsFunctions.execute(functionName, arguments.subList(1, arguments.size())); } }
ExecRhsFunction extends AbstractRhsFunctionHandler { @Override public Symbol execute(RhsFunctionContext context, List<Symbol> arguments) throws RhsFunctionException { RhsFunctions.checkArgumentCount(this, arguments); final String functionName = arguments.get(0).toString(); if(functionName.equals(getName())) { throw new RhsFunctionException("'exec' RHS function calling itself"); } return rhsFunctions.execute(functionName, arguments.subList(1, arguments.size())); } ExecRhsFunction(RhsFunctionManager rhsFunctions); }
ExecRhsFunction extends AbstractRhsFunctionHandler { @Override public Symbol execute(RhsFunctionContext context, List<Symbol> arguments) throws RhsFunctionException { RhsFunctions.checkArgumentCount(this, arguments); final String functionName = arguments.get(0).toString(); if(functionName.equals(getName())) { throw new RhsFunctionException("'exec' RHS function calling itself"); } return rhsFunctions.execute(functionName, arguments.subList(1, arguments.size())); } ExecRhsFunction(RhsFunctionManager rhsFunctions); @Override Symbol execute(RhsFunctionContext context, List<Symbol> arguments); @Override boolean mayBeStandalone(); }
ExecRhsFunction extends AbstractRhsFunctionHandler { @Override public Symbol execute(RhsFunctionContext context, List<Symbol> arguments) throws RhsFunctionException { RhsFunctions.checkArgumentCount(this, arguments); final String functionName = arguments.get(0).toString(); if(functionName.equals(getName())) { throw new RhsFunctionException("'exec' RHS function calling itself"); } return rhsFunctions.execute(functionName, arguments.subList(1, arguments.size())); } ExecRhsFunction(RhsFunctionManager rhsFunctions); @Override Symbol execute(RhsFunctionContext context, List<Symbol> arguments); @Override boolean mayBeStandalone();  }