You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by jt...@apache.org on 2019/05/02 16:05:01 UTC

[netbeans-html4j] branch master updated: Call typeof via a global function

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


The following commit(s) were added to refs/heads/master by this push:
     new 47f058d  Call typeof via a global function
47f058d is described below

commit 47f058df46a357088b8f34728f4acfd8396b5610
Author: Jaroslav Tulach <ja...@apidesign.org>
AuthorDate: Thu May 2 18:04:28 2019 +0200

    Call typeof via a global function
---
 .../src/main/java/net/java/html/json/tests/KnockoutTest.java | 12 ++++++++----
 json-tck/src/main/java/net/java/html/json/tests/Utils.java   | 12 ++++++++++++
 2 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/json-tck/src/main/java/net/java/html/json/tests/KnockoutTest.java b/json-tck/src/main/java/net/java/html/json/tests/KnockoutTest.java
index f0bdcc3..cc3b07f 100644
--- a/json-tck/src/main/java/net/java/html/json/tests/KnockoutTest.java
+++ b/json-tck/src/main/java/net/java/html/json/tests/KnockoutTest.java
@@ -392,8 +392,9 @@ public final class KnockoutTest {
     }
 
     @KOTest public void nonMutableDouble() throws Exception {
+        Utils.exposeTypeOf(KnockoutTest.class);
         Utils.exposeHTML(KnockoutTest.class,
-            "Type: <input id='input' data-bind=\"value: typeof doubleValue\"></input>\n"
+            "Type: <input id='input' data-bind=\"value: getTypeof(doubleValue)\"></input>\n"
         );
 
         ConstantModel model = Models.bind(new ConstantModel(), newContext());
@@ -407,8 +408,9 @@ public final class KnockoutTest {
     }
 
     @KOTest public void nonMutableString() throws Exception {
+        Utils.exposeTypeOf(KnockoutTest.class);
         Utils.exposeHTML(KnockoutTest.class,
-            "Type: <input id='input' data-bind=\"value: typeof stringValue\"></input>\n"
+            "Type: <input id='input' data-bind=\"value: getTypeof(stringValue)\"></input>\n"
         );
 
         ConstantModel model = Models.bind(new ConstantModel(), newContext());
@@ -422,8 +424,9 @@ public final class KnockoutTest {
     }
 
     @KOTest public void nonMutableBoolean() throws Exception {
+        Utils.exposeTypeOf(KnockoutTest.class);
         Utils.exposeHTML(KnockoutTest.class,
-            "Type: <input id='input' data-bind=\"value: typeof boolValue\"></input>\n"
+            "Type: <input id='input' data-bind=\"value: getTypeof(boolValue)\"></input>\n"
         );
 
         ConstantModel model = Models.bind(new ConstantModel(), newContext());
@@ -437,8 +440,9 @@ public final class KnockoutTest {
     }
 
     @KOTest public void nonMutableIntArray() throws Exception {
+        Utils.exposeTypeOf(KnockoutTest.class);
         Utils.exposeHTML(KnockoutTest.class,
-            "Type: <input id='input' data-bind=\"value: typeof intArray\"></input>\n"
+            "Type: <input id='input' data-bind=\"value: getTypeof(intArray)\"></input>\n"
         );
 
         ConstantModel model = Models.bind(new ConstantModel(), newContext());
diff --git a/json-tck/src/main/java/net/java/html/json/tests/Utils.java b/json-tck/src/main/java/net/java/html/json/tests/Utils.java
index d210134..faa346c 100644
--- a/json-tck/src/main/java/net/java/html/json/tests/Utils.java
+++ b/json-tck/src/main/java/net/java/html/json/tests/Utils.java
@@ -104,6 +104,18 @@ public final class Utils {
         }
         return ServiceLoader.load(KnockoutTCK.class, cl(clazz));
     }
+
+    static void exposeTypeOf(Class<?> clazz) throws Exception {
+        String s =
+          "var global = 0 || eval('this');\n" +
+          "if (!global['getTypeof']) {\n" +
+          "  global['getTypeof'] = function (o) {\n" +
+          "    return typeof o;\n" +
+          "  };\n" +
+          "}\n" +
+          "\n";
+        executeScript(clazz, s);
+    }
     
     static Object exposeHTML(Class<?> clazz, String html) throws Exception {
         String s = 


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

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