File tree Expand file tree Collapse file tree 3 files changed +23
-5
lines changed Expand file tree Collapse file tree 3 files changed +23
-5
lines changed Original file line number Diff line number Diff line change @@ -12273,7 +12273,7 @@ reduces them without incurring seq initialization"
1227312273 (when (nil? NS_CACHE)
1227412274 (set! NS_CACHE (atom {})))
1227512275 (let [ns-str (str_ ns )
12276- ns (if (not ^boolean (gstring/contains ns-str " $macros" ))
12276+ ns (if (not (gstring/contains ns-str " $macros" ))
1227712277 (symbol (str_ ns-str " $macros" ))
1227812278 ns )
1227912279 the-ns (get @NS_CACHE ns )]
@@ -12297,7 +12297,7 @@ reduces them without incurring seq initialization"
1229712297 [x]
1229812298 (instance? goog.Uri x))
1229912299
12300- (defn ^boolean NaN?
12300+ (defn NaN?
1230112301 " Returns true if num is NaN, else false"
1230212302 [val]
1230312303 (js/isNaN val))
@@ -12326,6 +12326,7 @@ reduces them without incurring seq initialization"
1232612326 [s]
1232712327 (if (string? s)
1232812328 (cond
12329+ ; ; FIXME: another cases worth thinking about
1232912330 ^boolean (re-matches #"[\x 00-\x 20]*[+-]?NaN[\x 00-\x 20]*" s) ##NaN
1233012331 ^boolean (re-matches
1233112332 #"[\x 00-\x 20]*[+-]?(Infinity|((\d +\. ?\d *|\.\d +)([eE][+-]?\d +)?)[dDfF]?)[\x 00-\x 20]*"
Original file line number Diff line number Diff line change 382382 '[(if (.isNaN js/Number 1 ) true false )]))]
383383 (is (nil? (re-find #"truth_" code))))))
384384
385+ (deftest test-goog-lib-infer-boolean
386+ (testing " Can infer goog.string/contains returns boolean"
387+ (let [code (env/with-compiler-env (env/default-compiler-env )
388+ (compile-form-seq
389+ '[(ns test.foo
390+ (:require [goog.string :as gstring]))
391+ (if (gstring/contain " foobar" " foo" ) true false )]))]
392+ (is (nil? (re-find #"truth_" code))))))
393+
385394; ; CLJS-1225
386395
387396(comment
Original file line number Diff line number Diff line change 395395 (Html5History. )]
396396 {} true ))))))
397397
398- ; ; FIXME: infers any instead of boolean, nothing wrong w/ the externs parsing
399- ; ; but this definitely does not work at the moment
400- #_(deftest test-goog-infer
398+ (deftest test-goog-infer
401399 (is (= 'boolean
400+ (:tag (env/with-compiler-env (env/default-compiler-env )
401+ (ana/analyze-form-seq
402+ '[(ns test.foo
403+ (:require [goog.string :as gstring]))
404+ (gstring/contains " foobar" " foo" )]
405+ {} true )))))
406+ ; ; FIXME: infers any instead of boolean, nothing wrong w/ the externs parsing
407+ ; ; but this definitely does not work at the moment
408+ #_ (is (= 'boolean
402409 (:tag
403410 (env/with-compiler-env (env/default-compiler-env )
404411 (ana/analyze-form-seq
405412 '[(ns test.foo
406413 (:require [goog.object :as gobject]))
407414 (gobject/containsKey (js-object ) " foo" )]
408415 {} true ))))))
416+
You can’t perform that action at this time.
0 commit comments