605 e.put("arr", arr); |
605 e.put("arr", arr); |
606 final Object res = e.eval("var res; with(arr[0]) { res = foo; }; res"); |
606 final Object res = e.eval("var res; with(arr[0]) { res = foo; }; res"); |
607 assertEquals(res, "hello"); |
607 assertEquals(res, "hello"); |
608 } |
608 } |
609 |
609 |
|
610 // @bug 8050432:javax.script.filename variable should not be enumerable |
|
611 // with nashorn engine's ENGINE_SCOPE bindings |
|
612 @Test |
|
613 public void enumerableGlobalsTest() throws ScriptException { |
|
614 final ScriptEngineManager m = new ScriptEngineManager(); |
|
615 final ScriptEngine e = m.getEngineByName("nashorn"); |
|
616 |
|
617 e.put(ScriptEngine.FILENAME, "test"); |
|
618 Object enumerable = e.eval( |
|
619 "Object.getOwnPropertyDescriptor(this, " + |
|
620 " 'javax.script.filename').enumerable"); |
|
621 assertEquals(enumerable, Boolean.FALSE); |
|
622 } |
|
623 |
610 private static void checkProperty(final ScriptEngine e, final String name) |
624 private static void checkProperty(final ScriptEngine e, final String name) |
611 throws ScriptException { |
625 throws ScriptException { |
612 final String value = System.getProperty(name); |
626 final String value = System.getProperty(name); |
613 e.put("name", name); |
627 e.put("name", name); |
614 assertEquals(value, e.eval("java.lang.System.getProperty(name)")); |
628 assertEquals(value, e.eval("java.lang.System.getProperty(name)")); |