Skip to content

Commit

Permalink
Completing test case
Browse files Browse the repository at this point in the history
  • Loading branch information
mxro committed Jan 8, 2025
1 parent 1940ba2 commit dd4492f
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,20 @@
*/
public class TestIssue168_Error_Returns_Null {

@Test(expected = javax.script.ScriptException.class)
public static class IFail {
public void doIt() {
throw new Error("I tried my best but I failed");
}
}

@Test(expected = java.lang.Error.class)
public void test() throws ScriptCPUAbuseException, ScriptException, NoSuchMethodException {

NashornSandbox sandbox = NashornSandboxes.create();
try {
sandbox.setExecutor(Executors.newSingleThreadExecutor());
String code = "throw new Error('Something bad happened!!')";
sandbox.inject("iFail", new IFail());
String code = "iFail.doIt();";
sandbox.eval(code);
} finally {
sandbox.getExecutor().shutdown();
Expand Down

0 comments on commit dd4492f

Please sign in to comment.