From 4ec7f45f5ad608c93c48750bd4c1f907e46d1045 Mon Sep 17 00:00:00 2001 From: Eero Helenius Date: Thu, 9 Nov 2023 09:05:42 +0200 Subject: [PATCH] Refactor tests to use kwargs --- test/me/flowthing/pp_test.clj | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/test/me/flowthing/pp_test.clj b/test/me/flowthing/pp_test.clj index e9e0090..fee4b84 100644 --- a/test/me/flowthing/pp_test.clj +++ b/test/me/flowthing/pp_test.clj @@ -176,11 +176,11 @@ (deftest pprint-meta ;; clojure.pprint prints this incorrectly with meta - (binding [*print-meta* true *print-readably* false] - (is (= "{:a 1}\n" (pp-str (with-meta {:a 1} {:b 2}))))) + (is (= "{:a 1}\n" + (pp-str (with-meta {:a 1} {:b 2}) :print-meta true :print-readably false))) - (binding [*print-meta* true] - (is (= "{:a 1}\n" (pp-str (with-meta {:a 1} {})))))) + (is (= "{:a 1}\n" + (pp-str (with-meta {:a 1} {}) :print-meta true)))) (defrecord R [x]) @@ -195,15 +195,15 @@ (deftest pprint-reader-macro-edge-cases ;; do not print the reader macro character if the collection following the ;; character exceeds print level - (is (= "#\n" (binding [*print-level* 0] (pp-str '('#{boolean char floats}))))) - (is (= "(#)\n" (binding [*print-level* 1] (pp-str '('#{boolean char floats}))))) - (is (= "(#)\n" (binding [*print-length* 1 *print-level* 1] (pp-str '('#{boolean char floats}))))) + (is (= "#\n" (pp-str '('#{boolean char floats}) :print-level 0))) + (is (= "(#)\n" (pp-str '('#{boolean char floats}) :print-level 1))) + (is (= "(#)\n" (pp-str '('#{boolean char floats}) :print-length 1 :print-level 1))) ;; reader macro characters do not count towards *print-length* (is (= "(...)\n" - (binding [*print-length* 0] (pp-str '('#{boolean char floats}))))) + (pp-str '('#{boolean char floats}) :print-length 0))) (is (= "('#{boolean ...})\n" - (binding [*print-length* 1] (pp-str '('#{boolean char floats})))))) + (pp-str '('#{boolean char floats})) :print-length 1))) (deftest map-entry-separator (is (= "{:a 1, :b 2}\n" (pp-str {:a 1 :b 2}))) @@ -226,9 +226,7 @@ (is (re-matches obj-re (with-out-str (prn (T. {:a 1}))))) (is (re-matches obj-re (with-out-str (cpp/pprint (T. {:a 1}))))) (is (re-matches obj-re (pp-str (T. {:a 1})))) - - (binding [*print-level* 0] - (is (re-matches obj-re (pp-str (T. {:a 1})))))) + (is (re-matches obj-re (pp-str (T. {:a 1}) :print-level 0)))) (deftest pprint-dup (binding [*print-dup* true]