### Question:
JSRhinoScriptEngine implements IScriptEngine { @Override public void compile(String scriptName, String programStr) throws ScriptLoadException { String fileDir = this.getRelativeFileDir(scriptName); programStr = "var relDir = \"" + fileDir + "\";\n" + programStr; Script script = this.cx.compileString(programStr, scriptName, 1 - 2, null); this.scripts.put(scriptName, script); } JSRhinoScriptEngine(); @Override void compile(String scriptName, String programStr); @Override void loadFile(File file); @Override Object execFunc(String funcName, Object... args); @Override Object execFunc(String funcName); @Override Object execScript(String scriptName, Object... args); @Override void shutdown();  }### Answer:
@Test public void testCompile () throws ScriptLoadException { JSRhinoScriptEngine engine = new JSRhinoScriptEngine(); assertNull(engine.scripts.get("test")); engine.compile("test", "java.lang.System.out.println(\"test\");"); assertNotNull(engine.scripts.get("test")); }
@Test (expected = EvaluatorException.class) public void testCompileInvalideJS () throws ScriptLoadException { JSRhinoScriptEngine engine = new JSRhinoScriptEngine(); assertNull(engine.scripts.get("test")); engine.compile("test", "va test = 2;"); }