|
926 | 926 | ;; dotted :var
|
927 | 927 | (is (= [:host-field 'bar :host-field 'foo :var 'cljs.core/inc 'cljs.core/inc]
|
928 | 928 | (-> (ana inc.foo.bar)
|
929 |
| - ((juxt :op |
| 929 | + ((juxt :op |
930 | 930 | :field
|
931 | 931 | (comp :op :target)
|
932 | 932 | (comp :field :target)
|
|
936 | 936 | ;; dotted :local
|
937 | 937 | (is (= [:host-field 'c :host-field 'b :local 'a 'a]
|
938 | 938 | (-> (ana (let [a 1] a.b.c)) :body :ret
|
939 |
| - ((juxt :op |
| 939 | + ((juxt :op |
940 | 940 | :field
|
941 | 941 | (comp :op :target)
|
942 | 942 | (comp :field :target)
|
|
974 | 974 | (is (= (-> (ana (let [a 1] a)) :body :ret :form) 'a))
|
975 | 975 | (is (map? (-> (ana (let [a 1] a)) :body :ret :env)))
|
976 | 976 | ;; dotted :local
|
977 |
| - (is (= [:host-field 'c :host-field 'b :local 'a] |
| 977 | + (is (= [:host-field 'c :host-field 'b :local 'a] |
978 | 978 | (-> (ana (let [a 1] a.b.c)) :body :ret
|
979 |
| - ((juxt :op |
| 979 | + ((juxt :op |
980 | 980 | :field
|
981 | 981 | (comp :op :target)
|
982 | 982 | (comp :field :target)
|
983 | 983 | (comp :op :target :target)
|
984 | 984 | (comp :name :target :target))))))
|
985 | 985 | ;local shadow
|
986 | 986 | (is (= 'alert
|
987 |
| - (ana/no-warn (-> (ana (let [alert 1] js/alert)) :body |
| 987 | + (ana/no-warn (-> (ana (let [alert 1] js/alert)) :body |
988 | 988 | :env :locals
|
989 | 989 | (get 'alert)
|
990 | 990 | :name))))
|
991 | 991 | (is (= [:local 'alert]
|
992 |
| - (ana/no-warn (-> (ana (let [alert 1] js/alert)) :body :ret |
| 992 | + (ana/no-warn (-> (ana (let [alert 1] js/alert)) :body :ret |
993 | 993 | ((juxt :op :name))))))
|
994 | 994 | ;loop
|
995 | 995 | (is (= (-> (ana (loop [])) :op) :loop))
|
|
1020 | 1020 | ; :finally
|
1021 | 1021 | (is (= (-> (ana (try (finally 1))) :finally :op) :do))
|
1022 | 1022 | (is (= (-> (ana (try (finally 1))) :finally :ret :op) :const))
|
1023 |
| - ;TODO case |
| 1023 | + ;TODO case |
1024 | 1024 | (is (= (-> (ana (case 1)) :op) :let))
|
1025 | 1025 | (is (= (-> (ana (case 1)) :body :ret :op) :case))
|
1026 | 1026 | (is (= (-> (ana (case 1)) :body :ret :children) [:test :nodes :default]))
|
|
1063 | 1063 | ; :ns/:name
|
1064 | 1064 | (is (= ['cljs.core 'cljs.core/a] (-> (ana (def a 1)) ((juxt :ns :name)))))
|
1065 | 1065 | ; :var
|
1066 |
| - (is (= [:var 'cljs.core 'cljs.core/a 'a] |
| 1066 | + (is (= [:var 'cljs.core 'cljs.core/a 'a] |
1067 | 1067 | (-> (ana (def a 1)) :var
|
1068 | 1068 | ((juxt :op :ns :name :form)))))
|
1069 | 1069 | ; :init
|
|
1076 | 1076 | (is (= :do (-> (ana (deftype A [a] Object (toString [this] a))) :statements first :body :op)))
|
1077 | 1077 | ; field reference
|
1078 | 1078 | (is (= [:local :field]
|
1079 |
| - (-> (ana (deftype A [a] Object (toString [this] a))) |
| 1079 | + (-> (ana (deftype A [a] Object (toString [this] a))) |
1080 | 1080 | :statements first :body :ret :val :methods
|
1081 |
| - first :body :ret :body :ret |
| 1081 | + first :body :ret :body :ret |
1082 | 1082 | ((juxt :op :local)))))
|
1083 | 1083 | ;defrecord
|
1084 | 1084 | (is (= :defrecord (-> (ana (defrecord Ab [])) :body :statements first :ret :op)))
|
|
1139 | 1139 | (-> (ana (fn [])) :methods first :params)))
|
1140 | 1140 | (is (vector?
|
1141 | 1141 | (-> (ana (fn [a b])) :methods first :params)))
|
1142 |
| - (is (= [:binding 'a :arg] |
| 1142 | + (is (= [:binding 'a :arg] |
1143 | 1143 | (-> (ana (fn [a b])) :methods first :params
|
1144 | 1144 | first ((juxt :op :name :local)))))
|
1145 |
| - (is (= [:binding 'b :arg] |
| 1145 | + (is (= [:binding 'b :arg] |
1146 | 1146 | (-> (ana (fn [a b])) :methods first :params
|
1147 | 1147 | second ((juxt :op :name :local)))))
|
1148 | 1148 | ;if
|
|
1342 | 1342 | (is (= :throw (-> (ana (throw (js/Error. "bad"))) :op)))
|
1343 | 1343 | (is (= [:exception] (-> (ana (throw (js/Error. "bad"))) :children)))
|
1344 | 1344 | ; :exception
|
1345 |
| - (is (= [:js-var 'js 'js/Error] (-> (ana (throw (js/Error. "bad"))) :exception |
| 1345 | + (is (= [:js-var 'js 'js/Error] (-> (ana (throw (js/Error. "bad"))) :exception |
1346 | 1346 | :class
|
1347 | 1347 | ((juxt :op :ns :name)))))
|
1348 | 1348 | ;vector
|
|
1405 | 1405 | ;munging
|
1406 | 1406 | (is (=
|
1407 | 1407 | [false 'a]
|
1408 |
| - (-> |
| 1408 | + (-> |
1409 | 1409 | (ana (let [a (println 1)
|
1410 | 1410 | b (println 2)]
|
1411 | 1411 | [a b]))
|
1412 |
| - :bindings first |
| 1412 | + :bindings first |
1413 | 1413 | ((juxt #(contains? % :ns) :name)))))
|
1414 | 1414 | ;shadowing
|
1415 | 1415 | (is (=
|
1416 | 1416 | 'a
|
1417 |
| - (-> |
| 1417 | + (-> |
1418 | 1418 | (ana (let [a (println 1)
|
1419 | 1419 | a (println 2)]
|
1420 | 1420 | [a a]))
|
1421 |
| - :bindings second |
| 1421 | + :bindings second |
1422 | 1422 | :shadow
|
1423 | 1423 | :name)))
|
1424 | 1424 | (is (=
|
1425 | 1425 | 'a
|
1426 |
| - (-> |
| 1426 | + (-> |
1427 | 1427 | (ana (let [a (println 1)
|
1428 | 1428 | a (println 2)
|
1429 | 1429 | a (println 3)
|
1430 | 1430 | ]
|
1431 | 1431 | [a a a]))
|
1432 |
| - :bindings (nth 2) |
| 1432 | + :bindings (nth 2) |
1433 | 1433 | :shadow
|
1434 | 1434 | :shadow
|
1435 | 1435 | :name)))
|
1436 | 1436 | ;ns
|
1437 |
| - (is |
| 1437 | + (is |
1438 | 1438 | (binding [ana/*analyze-deps* false]
|
1439 | 1439 | (binding [ana/*cljs-ns* 'cljs.user]
|
1440 |
| - (ana |
| 1440 | + (ana |
1441 | 1441 | (ns my.ns.foo
|
1442 | 1442 | (:require [clojure.repl]
|
1443 | 1443 | [clojure.string]
|
|
2137 | 2137 | (is (= w2 "cljs.core/-, all arguments must be numbers, got [string] instead"))
|
2138 | 2138 | (is (= w3 "cljs.core//, all arguments must be numbers, got [number string] instead"))
|
2139 | 2139 | (is (= w4 "cljs.core/*, all arguments must be numbers, got [string] instead")))))
|
| 2140 | + |
| 2141 | +(deftest test-cljs-3181 |
| 2142 | + (let [ws (atom []) |
| 2143 | + res (binding [ana/*cljs-static-fns* true] |
| 2144 | + (infer-test-helper |
| 2145 | + {:forms '[(ns warn-on-infer-test.app) |
| 2146 | + (set! *warn-on-infer* true) |
| 2147 | + (defn f [gfn] |
| 2148 | + (.then ^js/Promise (gfn (inc 1)) identity))] |
| 2149 | + :externs ["src/test/externs/test.js"] |
| 2150 | + :warnings ws |
| 2151 | + :warn false |
| 2152 | + :with-core? true}))] |
| 2153 | + (is (empty? @ws)))) |
0 commit comments