Skip to content

Commit f81c8bb

Browse files
mfikesdnolen
authored and
dnolen
committed
CLJS-2711: System newline breaking some tests on Windows
1 parent 3392d2a commit f81c8bb

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

Diff for: src/test/clojure/cljs/analyzer_tests.clj

+9-8
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
[cljs.closure :as closure]
1818
[cljs.externs :as externs]
1919
[cljs.analyzer :as ana]
20-
[clojure.string :as string])
20+
[clojure.string :as string]
21+
[cljs.test-util :refer [unsplit-lines]])
2122
(:use clojure.test))
2223

2324
(defn collecting-warning-handler [state]
@@ -882,13 +883,13 @@
882883
(.apply (.-log js/console) js/console (into-array args)))
883884
(js/console.log js/Number.MAX_VALUE)
884885
(js/console.log js/Symbol.iterator)]})]
885-
(is (= "var React;\nReact.Component;\n" res))))
886+
(is (= (unsplit-lines ["var React;" "React.Component;"]) res))))
886887

887888
(deftest test-method-infer
888889
(let [res (infer-test-helper
889890
{:forms '[(defn foo [^js/React.Component c]
890891
(.render c))]})]
891-
(is (= "var React;\nReact.Component;\nReact.Component.prototype.render;\n"
892+
(is (= (unsplit-lines ["var React;" "React.Component;" "React.Component.prototype.render;"])
892893
res))))
893894

894895
(deftest test-minimal-infer
@@ -912,7 +913,7 @@
912913
(.wozz z)))]
913914
:externs ["src/test/externs/test.js"]
914915
:warnings ws})]
915-
(is (= "Foo.Boo.prototype.wozz;\n" res))
916+
(is (= (unsplit-lines ["Foo.Boo.prototype.wozz;"]) res))
916917
(is (= 1 (count @ws)))
917918
(is (string/starts-with?
918919
(first @ws)
@@ -926,7 +927,7 @@
926927
(.-wozz z)))]
927928
:externs ["src/test/externs/test.js"]
928929
:warnings ws})]
929-
(is (= "Foo.Boo.prototype.wozz;\n" res))
930+
(is (= (unsplit-lines ["Foo.Boo.prototype.wozz;"]) res))
930931
(is (= 1 (count @ws)))
931932
(is (string/starts-with?
932933
(first @ws)
@@ -939,7 +940,7 @@
939940
(.gozMethod a))]
940941
:externs ["src/test/externs/test.js"]
941942
:warnings ws})]
942-
(is (= "Foo.prototype.gozMethod;\n" res))
943+
(is (= (unsplit-lines ["Foo.prototype.gozMethod;"]) res))
943944
(is (= 1 (count @ws)))
944945
(is (string/starts-with?
945946
(first @ws)
@@ -951,7 +952,7 @@
951952
{:forms '[(.gozMethod (js/baz))]
952953
:externs ["src/test/externs/test.js"]
953954
:warnings ws})]
954-
(is (= "Foo.prototype.gozMethod;\n" res))
955+
(is (= (unsplit-lines ["Foo.prototype.gozMethod;"]) res))
955956
(is (= 1 (count @ws)))
956957
(is (string/starts-with?
957958
(first @ws)
@@ -965,7 +966,7 @@
965966
(.log js/console (.-Component React))]
966967
:externs ["src/test/externs/test.js"]
967968
:warnings ws})]
968-
(is (= "var require;\nObject.Component;\n" res))
969+
(is (= (unsplit-lines ["var require;" "Object.Component;"]) res))
969970
(is (= 1 (count @ws)))
970971
(is (string/starts-with?
971972
(first @ws)

Diff for: src/test/clojure/cljs/test_util.clj

+7
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,10 @@
6262

6363
(defn platform-path [path]
6464
(.replace path \/ (.charAt (str File/separator) 0)))
65+
66+
(defn unsplit-lines
67+
"Forms a string wherein each line is followed by a system-dependent newline.
68+
Roughly an inverse of clojure.string/split-lines."
69+
[lines]
70+
(with-out-str
71+
(run! println lines)))

0 commit comments

Comments
 (0)