@Test
public void functionalInterfaceObjectTest() throws Exception {
final ScriptEngineManager manager = new ScriptEngineManager();
final ScriptEngine e = manager.getEngineByName("nashorn");
final AtomicBoolean invoked = new AtomicBoolean(false);
e.put("c", new Consumer<Object>() {
@Override
public void accept(final Object t) {
assertTrue(t instanceof ScriptObjectMirror);
assertEquals(((ScriptObjectMirror)t).get("a"), "xyz");
invoked.set(true);
}
});
e.eval("var x = 'xy'; x += 'z';c({a:x})");
assertTrue(invoked.get());
}
ScriptEngineTest.java 文件源码
java
阅读 22
收藏 0
点赞 0
评论 0
项目:openjdk-jdk10
作者:
评论列表
文章目录