Skip to content

Commit

Permalink
test: refactor are->doseq (#281)
Browse files Browse the repository at this point in the history
When studying some metadata tests I converted them from `are` to `doseq`.
A personal pref that I find easier to maintain and grok and that I'll
move to for any tests I study/touch.

Was studying tests for #279 and #280
  • Loading branch information
lread authored Jun 18, 2024
1 parent 7d176f9 commit 6c4c6ea
Showing 1 changed file with 40 additions and 40 deletions.
80 changes: 40 additions & 40 deletions test/rewrite_clj/parser_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -227,48 +227,48 @@
"{:r 1 :u}" :map))

(deftest t-parsing-metadata
(are [?s ?t ?mt]
(let [s (str ?s " s")
n (p/parse-string s)
[mta ws sym] (node/children n)]
(is (= ?t (node/tag n)))
(is (= s (node/string n)))
(is (= 's (node/sexpr n)))
(is (= {:private true} (meta (node/sexpr n))))
(is (= ?mt (node/tag mta)))
(is (= :whitespace (node/tag ws)))
(is (= :token (node/tag sym)))
(is (= 's (node/sexpr sym))))
"^:private" :meta :token
"^{:private true}" :meta :map
"#^:private" :meta* :token
"#^{:private true}" :meta* :map))
(doseq [[meta-str expected-tag expected-meta-child-tag]
[["^:private" :meta :token]
["^{:private true}" :meta :map]
["#^:private" :meta* :token]
["#^{:private true}" :meta* :map]]
:let [s (str meta-str " s")
n (p/parse-string s)
[meta-data ws target-sym] (node/children n)]]
(is (= expected-tag (node/tag n)))
(is (= s (node/string n)))
(is (= 's (node/sexpr n)))
(is (= {:private true} (meta (node/sexpr n))))
(is (= expected-meta-child-tag (node/tag meta-data)))
(is (= :whitespace (node/tag ws)))
(is (= :token (node/tag target-sym)))
(is (= 's (node/sexpr target-sym)))))

(deftest t-parsing-multiple-metadata-forms
(are [?s ?expected-meta-tag ?expected-tag-on-metadata]
(let [s (str ?s " s")
n (p/parse-string s)
[mdata ws inner-n] (node/children n)
[inner-mdata inner-ws sym] (node/children inner-n)]
;; outer meta
(is (= ?expected-meta-tag (node/tag n)))
(is (= {:private true :awe true} (meta (node/sexpr n))))
(is (= ?expected-tag-on-metadata (node/tag mdata)))
(is (= :whitespace (node/tag ws)))

;; inner meta
(is (= ?expected-meta-tag (node/tag inner-n)))
(is (= {:awe true} (meta (node/sexpr inner-n))))
(is (= ?expected-tag-on-metadata (node/tag inner-mdata)))
(is (= :whitespace (node/tag inner-ws)))

;; symbol
(is (= s (node/string n)))
(is (= 's (node/sexpr sym))))
"^:private ^:awe" :meta :token
"^{:private true} ^{:awe true}" :meta :map
"#^:private #^:awe" :meta* :token
"#^{:private true} #^{:awe true}" :meta* :map))
(doseq [[meta-str expected-meta-tag expected-tag-on-metadata]
[["^:private ^:awe" :meta :token]
["^{:private true} ^{:awe true}" :meta :map]
["#^:private #^:awe" :meta* :token]
["#^{:private true} #^{:awe true}" :meta* :map]]
:let [s (str meta-str " s")
n (p/parse-string s)
[meta-data ws inner-node] (node/children n)
[inner-meta-data inner-ws target-sym] (node/children inner-node)]]
;; outer metadata
(is (= expected-meta-tag (node/tag n)))
(is (= {:private true :awe true} (meta (node/sexpr n))))
(is (= expected-tag-on-metadata (node/tag meta-data)))
(is (= :whitespace (node/tag ws)))

;; inner metadata
(is (= expected-meta-tag (node/tag inner-node)))
(is (= {:awe true} (meta (node/sexpr inner-node))))
(is (= expected-tag-on-metadata (node/tag inner-meta-data)))
(is (= :whitespace (node/tag inner-ws)))

;; target symbol
(is (= s (node/string n)))
(is (= 's (node/sexpr target-sym)))))

(deftest t-parsing-reader-macros
(are [?s ?t ?children]
Expand Down

0 comments on commit 6c4c6ea

Please sign in to comment.