Skip to content

Commit ba18d9f

Browse files
mfikesdnolen
authored and
dnolen
committed
CLJS-1592: Self-host: Robustness for core tests
A couple minor things that can be improved in the core tests which facilitates running them in bootstrapped environments: 1. Restore *print-newline* 2. Add a little more order robustness for hash-based collections
1 parent 757b759 commit ba18d9f

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

src/test/cljs/cljs/core_test.cljs

+18-14
Original file line numberDiff line numberDiff line change
@@ -1582,8 +1582,9 @@
15821582
(is (.-done (.next iter)))))
15831583
(let [eiter (.entries {:foo "bar" :baz "woz"})]
15841584
(testing "map entry iteration"
1585-
(is (= (seq (.-value (.next eiter))) (seq #js [:foo "bar"])))
1586-
(is (= (seq (.-value (.next eiter))) (seq #js [:baz "woz"])))
1585+
(let [entries #{(seq #js [:foo "bar"]) (seq #js [:baz "woz"])}]
1586+
(is (entries (seq (.-value (.next eiter)))))
1587+
(is (entries (seq (.-value (.next eiter))))))
15871588
(is (.-done (.next eiter)))))
15881589
(let [iter (.values {:foo "bar" :baz "woz"})]
15891590
(testing "map value iteration"
@@ -1643,10 +1644,10 @@
16431644
"{:foo \"bar\"}"))
16441645
(is (= (binding [*print-length* 0] (str {:foo "bar" :baz "woz"}))
16451646
"{...}"))
1646-
(is (= (binding [*print-length* 1] (str {:foo "bar" :baz "woz"}))
1647-
"{:foo \"bar\", ...}"))
1648-
(is (= (binding [*print-length* 10] (str {:foo "bar" :baz "woz"}))
1649-
"{:foo \"bar\", :baz \"woz\"}")))
1647+
(is (#{"{:foo \"bar\", ...}" "{:baz \"woz\", ...}"}
1648+
(binding [*print-length* 1] (str {:foo "bar" :baz "woz"}))))
1649+
(is (#{"{:foo \"bar\", :baz \"woz\"}" "{:baz \"woz\", :foo \"bar\"}"}
1650+
(binding [*print-length* 10] (str {:foo "bar" :baz "woz"})))))
16501651
)
16511652

16521653
(deftest test-print-with-opts
@@ -1656,12 +1657,16 @@
16561657
"[<MORE-MARKER>]"))
16571658
(is (= (pr-str-with-opts [[1 2 3]] {:more-marker "\u2026" :print-length 1})
16581659
"[1 \u2026]"))
1659-
(is (= (pr-str-with-opts [#{1 2 3}] {:more-marker "\u2026" :print-length 2})
1660-
"#{1 3 \u2026}"))
1660+
(is (#{"#{1 2 \u2026}" "#{1 3 \u2026}"
1661+
"#{2 1 \u2026}" "#{2 3 \u2026}"
1662+
"#{3 1 \u2026}" "#{3 2 \u2026}"}
1663+
(pr-str-with-opts [#{1 2 3}] {:more-marker "\u2026" :print-length 2})))
16611664
(is (= (pr-str-with-opts ['(1 2 3)] {:more-marker "\u2026" :print-length 2})
16621665
"(1 2 \u2026)"))
1663-
(is (= (pr-str-with-opts [{:1 1 :2 2 :3 3}] {:more-marker "\u2026" :print-length 2})
1664-
"{:1 1, :2 2, \u2026}")))
1666+
(is (#{"{:1 1, :2 2, \u2026}" "{:1 1, :3 3, \u2026}"
1667+
"{:2 2, :1 1, \u2026}" "{:2 2, :3 3, \u2026}"
1668+
"{:3 3, :1 1, \u2026}" "{:3 3, :2 2, \u2026}"}
1669+
(pr-str-with-opts [{:1 1 :2 2 :3 3}] {:more-marker "\u2026" :print-length 2}))))
16651670

16661671
(testing "Testing printing with opts - :alt-impl"
16671672
; CLJS-1010
@@ -2429,10 +2434,9 @@
24292434

24302435
(deftest test-739
24312436
(testing "Testing CLJS-739, with-out-str"
2432-
(set! *print-newline* true)
2433-
(is (= (with-out-str (doseq [fn (cljs-739 [] [:a :b :c :d])] (fn)))
2434-
":a\n:b\n:c\n:d\n"))
2435-
(set! *print-newline* false)))
2437+
(binding [*print-newline* true]
2438+
(is (= (with-out-str (doseq [fn (cljs-739 [] [:a :b :c :d])] (fn)))
2439+
":a\n:b\n:c\n:d\n")))))
24362440

24372441
(deftest test-728
24382442
(testing "Testing CLJS-728, lookup with default"

0 commit comments

Comments
 (0)