[prev in list] [next in list] [prev in thread] [next in thread]
List: htmlunit-develop
Subject: [HtmlUnit] SVN: [13271] trunk/js/src/test/java/com/gargoylesoftware/js/nashorn/
From: asashour () users ! sourceforge ! net
Date: 2016-12-22 12:38:40
Message-ID: E1cK2dv-0007MF-EZ () sfs-ml-4 ! v29 ! ch3 ! sourceforge ! com
[Download RAW message or body]
Revision: 13271
http://sourceforge.net/p/htmlunit/code/13271
Author: asashour
Date: 2016-12-22 12:38:39 +0000 (Thu, 22 Dec 2016)
Log Message:
-----------
js3: test case
Modified Paths:
--------------
trunk/js/src/test/java/com/gargoylesoftware/js/nashorn/internal/runtime/ScriptFunctionTest.java
Modified: trunk/js/src/test/java/com/gargoylesoftware/js/nashorn/internal/runtime/ScriptFunctionTest.java
===================================================================
--- trunk/js/src/test/java/com/gargoylesoftware/js/nashorn/internal/runtime/ScriptFunctionTest.java 2016-12-21 \
11:37:35 UTC (rev 13270)
+++ trunk/js/src/test/java/com/gargoylesoftware/js/nashorn/internal/runtime/ScriptFunctionTest.java 2016-12-22 \
12:38:39 UTC (rev 13271) @@ -31,7 +31,7 @@
public class ScriptFunctionTest {
@Test
- public void simpleScriptFunction() throws Exception {
+ public void simple() throws Exception {
final Browser chrome = new Browser(BrowserFamily.CHROME, 55);
final NashornScriptEngine engine = createEngine();
final Global global = initGlobal(engine, chrome);
@@ -146,7 +146,7 @@
}
@Test
- public void fullScriptFunction() throws Exception {
+ public void withDeclaration() throws Exception {
final Browser chrome = new Browser(BrowserFamily.CHROME, 55);
final NashornScriptEngine engine = createEngine();
final Global global = initGlobal(engine, chrome);
@@ -168,4 +168,31 @@
}
}
+ @Test
+ public void useFromAnother() throws Exception {
+ final Browser chrome = new Browser(BrowserFamily.CHROME, 55);
+ final NashornScriptEngine engine = createEngine();
+ final Global global = initGlobal(engine, chrome);
+ final String code1 = "function test1(name) {return test2(name)}";
+ final String code2 = "function test2(event) {return 'hello ' + event}";
+
+ final Source source1 = Source.sourceFor("some name", code1);
+ final Source source2 = Source.sourceFor("some name2", code2);
+ final Global oldGlobal = Context.getGlobal();
+ try {
+ Context.setGlobal(global);
+ final ScriptFunction event1Handler = \
global.getContext().compileScript(source1, global); + \
ScriptRuntime.apply(event1Handler, global); + final ScriptFunction \
event2Handler = global.getContext().compileScript(source2, global); + \
ScriptRuntime.apply(event2Handler, global); +
+ final ScriptFunction test1Function = (ScriptFunction) \
global.get("test1"); + final Object value = \
ScriptRuntime.apply(test1Function, global, "there"); + assertEquals("hello \
there", value.toString()); + }
+ finally {
+ Context.setGlobal(oldGlobal);
+ }
+ }
+
}
------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today.http://sdm.link/intel
_______________________________________________
HtmlUnit-develop mailing list
HtmlUnit-develop@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/htmlunit-develop
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic