use of io.github.wysohn.triggerreactor.core.script.interpreter.Interpreter in project TriggerReactor by wysohn.
the class TriggerTest method testArray.
@Test
public void testArray() throws Exception {
Charset charset = Charset.forName("UTF-8");
String text = "" + "args[0] = \"arg1\"\n" + "args[1] = \"arg2\"\n" + "#MESSAGE args[0]+\", \"+args[1*-1*-1+1-1--1-1]\n";
Lexer lexer = new Lexer(text, charset);
Parser parser = new Parser(lexer);
Node root = parser.parse();
Map<String, Executor> executorMap = new HashMap<>();
executorMap.put("MESSAGE", new Executor() {
@Override
public Integer execute(boolean sync, Object context, Object... args) {
Assert.assertEquals("arg1, arg2", args[0]);
return null;
}
});
Map<String, Object> map = new HashMap<String, Object>();
Interpreter interpreter = new Interpreter(root, executorMap, new HashMap<>(), map, new HashMap<>(), new CommonFunctions(null));
String[] args = new String[] { "item1", "item2" };
interpreter.getVars().put("args", args);
interpreter.startWithContext(null);
}
Aggregations