@Test public void testBooleanExpression() throws Exception{ Assert.assertEquals(mEvalutor.calculate("true == false"), "false", "true is never false"); Assert.assertEquals( mEvalutor.calculate("5 > 0"), "true", "this always holds"); }
public static String calculate(String calculation) throws Exception{ ScriptEngineManager mgr = new ScriptEngineManager(); ScriptEngine engine = mgr.getEngineByName("JavaScript"); return engine.eval(calculation).toString(); }
Evaluator { public static String calculate(String calculation) throws Exception{ ScriptEngineManager mgr = new ScriptEngineManager(); ScriptEngine engine = mgr.getEngineByName("JavaScript"); return engine.eval(calculation).toString(); } }
Evaluator { public static String calculate(String calculation) throws Exception{ ScriptEngineManager mgr = new ScriptEngineManager(); ScriptEngine engine = mgr.getEngineByName("JavaScript"); return engine.eval(calculation).toString(); }  }
Evaluator { public static String calculate(String calculation) throws Exception{ ScriptEngineManager mgr = new ScriptEngineManager(); ScriptEngine engine = mgr.getEngineByName("JavaScript"); return engine.eval(calculation).toString(); }  static String calculate(String calculation); }
Evaluator { public static String calculate(String calculation) throws Exception{ ScriptEngineManager mgr = new ScriptEngineManager(); ScriptEngine engine = mgr.getEngineByName("JavaScript"); return engine.eval(calculation).toString(); }  static String calculate(String calculation);  }