|
56 | 56 |
|
57 | 57 | (deftest wrapper-method-test |
58 | 58 | (testing "" |
59 | | - (is (function? js/Array)) |
| 59 | + ;; (is (function? js/Array)) |
60 | 60 | (is (= (polyglot/get-meta-qualified-name (polyglot/get-meta-object js/Array)) |
61 | 61 | "Function")) |
62 | 62 | (is (= (polyglot/get-meta-qualified-name (polyglot/get-meta-object (polyglot/get-member js/Array "from"))) |
|
70 | 70 |
|
71 | 71 | (deftest polyglot-value?-test |
72 | 72 | (testing "" |
73 | | - (is (true? (fn? js/Array)) "js/Array is a clojure fn") |
74 | | - (is (boolean (polyglot/polyglot-value js/Array)) "js/Array is also a polyglot value") |
75 | | - (is (isa? (class (polyglot/polyglot-value js/Array)) |
76 | | - org.graalvm.polyglot.Value) "It returns the wrapped Value"))) |
| 73 | + (is (true? (symbol? js/Array)) "js/Array is just a symbol now") |
| 74 | + (is (instance? org.graalvm.polyglot.Value (polyglot/polyglot-value js/Array) ) "We turn it into a polyglot value using polyglot-value") |
| 75 | + (is (true? (fn? (converting/clojurify-value (polyglot/polyglot-value js/Array)))) "We can't use it as a function now, maybe we need to solve this problem in the future"))) |
| 76 | + |
| 77 | +(deftest special-js-namespace-test |
| 78 | + (testing "" |
| 79 | + (is (symbol? js/Array) |
| 80 | + "It is just a symbol") |
| 81 | + (is (= (js->clj (core/js-new js/Array 1 2 3)) |
| 82 | + [1 2 3]) |
| 83 | + "We can use it as the class") |
| 84 | + (is (= (js->clj (core/js-new js/Array js/undefined js/undefined)) |
| 85 | + [nil nil]) |
| 86 | + "We can pass it as arguments") |
| 87 | + (is (true? (core/js-fn? js/Array)) |
| 88 | + "functions starting with js- will treat these symbols as js values"))) |
77 | 89 |
|
78 | 90 | (deftest js-array?-test |
79 | 91 | (testing "" |
|
82 | 94 | (is (false? (core/js-array? js/undefined)) "returns false, no error threw"))) |
83 | 95 |
|
84 | 96 | (deftest js->clj-test |
85 | | - (testing "Default testing" |
86 | | - (is (nil? (js->clj js/undefined))) |
87 | | - (is (fn? (js->clj js/Array)))) |
88 | 97 |
|
89 | 98 | (testing "Testing builitn types, they should be returned as is" |
90 | 99 | (is (nil? (js->clj nil))) |
|
216 | 225 |
|
217 | 226 | (deftest executable-javascript-object-test |
218 | 227 | (testing "" |
219 | | - (is (function? js/Array) "It is a clojure function") |
| 228 | + (is (not (function? js/Array)) "We can not use it as a Clojure function now") |
220 | 229 | (is (core/js-fn? js/Array) "It is also a javascript function") |
221 | 230 | (is (polyglot/can-instantiate js/Array) "We can also instantiate it") |
222 | 231 | (is (polyglot/get-member js/Array "from") "We can get its static method") |
|
0 commit comments