1   package delight.nashornsandbox.tests;
2   
3   import delight.nashornsandbox.NashornSandbox;
4   import delight.nashornsandbox.NashornSandboxes;
5   import jdk.nashorn.api.scripting.ScriptObjectMirror;
6   import org.junit.Assert;
7   import org.junit.Test;
8   
9   @SuppressWarnings("all")
10  public class TestAccessFunction {
11    @Test
12    public void test_access_variable() {
13      final NashornSandbox sandbox = NashornSandboxes.create();
14      sandbox.eval("function callMe() { return 42; };");
15      Object _get = sandbox.get("callMe");
16      Assert.assertEquals(Integer.valueOf(42), ((ScriptObjectMirror) _get).call(this));
17      Object _eval = sandbox.eval("callMe");
18      Assert.assertEquals(Integer.valueOf(42), ((ScriptObjectMirror) _eval).call(this));
19    }
20  }