This is an automated email from the ASF dual-hosted git repository.

jtulach pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans-html4j.git

commit be94a6b7de1ff3a444ad0454137fe4722ce0c814
Author: Jaroslav Tulach <jaroslav.tul...@apidesign.org>
AuthorDate: Wed Jul 6 10:20:14 2022 +0200

    Check Promise.then isn't called prematurelly
---
 .../java/net/java/html/js/tests/AsyncJavaTest.java     | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/json-tck/src/main/java/net/java/html/js/tests/AsyncJavaTest.java 
b/json-tck/src/main/java/net/java/html/js/tests/AsyncJavaTest.java
index 4c8f63b7..aac69f4f 100644
--- a/json-tck/src/main/java/net/java/html/js/tests/AsyncJavaTest.java
+++ b/json-tck/src/main/java/net/java/html/js/tests/AsyncJavaTest.java
@@ -19,6 +19,7 @@
 package net.java.html.js.tests;
 
 import static net.java.html.js.tests.JavaScriptBodyTest.assertEquals;
+import static net.java.html.js.tests.JavaScriptBodyTest.assertFalse;
 import net.java.html.json.tests.PhaseExecutor;
 import org.netbeans.html.json.tck.KOTest;
 
@@ -28,19 +29,20 @@ public class AsyncJavaTest {
     @KOTest
     public void dontWaitForJavaFactorial() throws Exception {
         PhaseExecutor.schedule(phases, () -> {
-            boolean[] javaExecuted = { false };
-            Object objWithX = AsyncJava.computeInAsyncJava(5, (n) -> {
+            Object[] arr = { null, false };
+            arr[0] = AsyncJava.computeInAsyncJava(5, (n) -> {
                 int acc = 1;
                 for (int i = 1; i <= n; i++) {
                     acc *= i;
                 }
                 return acc;
-            }, () -> {});
-            int initialValue = Bodies.readIntX(objWithX);
-            assertEquals(-1, initialValue, "Promise.then shall only be called 
when the code ends");
-            return objWithX;
-        }).then((objWithX) -> {
-            int result = Bodies.readIntX(objWithX);
+            }, () -> {
+                arr[1] = true;
+            });
+            assertFalse((Boolean) arr[1], "Promise.then shall only be called 
when the code ends");
+            return arr;
+        }).then((arr) -> {
+            int result = Bodies.readIntX(arr[0]);
             assertEquals(result, 120);
         }).start();
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@netbeans.apache.org
For additional commands, e-mail: commits-h...@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to