Skip to content

Commit

Permalink
* remove unneeded warnings
Browse files Browse the repository at this point in the history
* add defrecord
  • Loading branch information
swannodette committed Oct 29, 2024
1 parent 3e630af commit 2cc8c5c
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions src/test/clojure/cljs/analyzer/spec_tests.clj
Original file line number Diff line number Diff line change
Expand Up @@ -60,30 +60,40 @@
(let [node (no-warn (analyze ns-env '(def x)))]
(is (= :def (:op node)))
(is (s/valid? ::a/node node)))
(is (s/valid? ::a/node (no-warn (analyze ns-env '(def x 1)))))
(is (s/valid? ::a/node (no-warn (analyze ns-env '(def x (fn []))))))
(is (s/valid? ::a/node (no-warn (analyze ns-env '(def x (fn [y] y)))))))
(is (s/valid? ::a/node (analyze ns-env '(def x 1))))
(is (s/valid? ::a/node (analyze ns-env '(def x (fn [])))))
(is (s/valid? ::a/node (analyze ns-env '(def x (fn [y] y))))))

(deftest test-fn
(let [node (no-warn (analyze ns-env '(fn [])))]
(is (= :fn (:op node)))
(is (s/valid? ::a/node node)))
(is (s/valid? ::a/node (no-warn (analyze ns-env '(fn [] 1)))))
(is (s/valid? ::a/node (no-warn (analyze ns-env '(fn [x])))))
(is (s/valid? ::a/node (no-warn (analyze ns-env '(fn [x] 1))))))
(is (s/valid? ::a/node (analyze ns-env '(fn [] 1))))
(is (s/valid? ::a/node (analyze ns-env '(fn [x]))))
(is (s/valid? ::a/node (analyze ns-env '(fn [x] 1)))))

(deftest test-defn
(is (s/valid? ::a/node (no-warn (analyze ns-env '(defn x [])))))
(is (s/valid? ::a/node (no-warn (analyze ns-env '(defn x [] 1)))))
(is (s/valid? ::a/node (no-warn (analyze ns-env '(defn x [y] y))))))
(is (s/valid? ::a/node (analyze ns-env '(defn x []))))
(is (s/valid? ::a/node (analyze ns-env '(defn x [] 1))))
(is (s/valid? ::a/node (analyze ns-env '(defn x [y] y)))))

(deftest test-new
(let [node (no-warn (analyze ns-env '(new String)))]
(is (= :new (:op node)))
(is (s/valid? ::a/node node)))
(is (s/valid? ::a/node (no-warn (analyze ns-env '(new js/String)))))
(is (s/valid? ::a/node (analyze ns-env '(new js/String))))
(is (s/valid? ::a/node (no-warn (analyze ns-env '(String.)))))
(is (s/valid? ::a/node (no-warn (analyze ns-env '(js/String.))))))
(is (s/valid? ::a/node (analyze ns-env '(js/String.)))))

(deftest test-defrecord
(let [node (no-warn (analyze ns-env '(defrecord A [])))
body (:body node)]
(is (= :defrecord (->> body :statements first :ret :op)))
(is (s/valid? ::a/node node))))

; TODO: #js
;(deftest test-js-object
; )

(comment

Expand Down

0 comments on commit 2cc8c5c

Please sign in to comment.