Skip to content

Commit c28e41a

Browse files
mfikesdnolen
authored andcommitted
CLJS-1831: Self-host: Improperly munge ns names
In self-hosted, munge namespaces using comp/munge, just as is done in regular ClojureScript. Add unit tests for both regular and self-hosted that exercise the munging feature.
1 parent 8c9cde9 commit c28e41a

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

src/main/cljs/cljs/js.cljs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@
663663
(fn [res]
664664
(if (:error res)
665665
(cb res)
666-
(let [src (str "goog.provide(\"" (munge (:name ast)) "\")")]
666+
(let [src (str "goog.provide(\"" (comp/munge (:name ast)) "\")")]
667667
(cb {:value (*eval-fn* {:source src})})))))
668668
(let [src (with-out-str (comp/emit ast))]
669669
(cb {:value (*eval-fn* {:source src})})))))))))
@@ -873,7 +873,7 @@
873873
(if (#{:ns :ns*} (:op ast))
874874
(do
875875
(.append sb
876-
(with-out-str (comp/emitln (str "goog.provide(\"" (munge (:name ast)) "\");"))))
876+
(with-out-str (comp/emitln (str "goog.provide(\"" (comp/munge (:name ast)) "\");"))))
877877
(ns-side-effects true bound-vars aenv ast opts
878878
(fn [res]
879879
(if (:error res)

src/test/cljs/static/core_test.cljs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
(ns static.core-test
2+
(:require [cljs.test :refer-macros [deftest is]]))
3+
4+
; The purpose of this test namespace is to ensure
5+
; that the use of a reserved JavaScript keyword
6+
; (`static`) in the namespace is handled properly.
7+
8+
(deftest foo-test
9+
(is (= 1 1)))

src/test/cljs/test_runner.cljs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@
3939
[cljs.hash-map-test]
4040
[cljs.predicates-test]
4141
[cljs.tagged-literals-test]
42-
[cljs.test-test]))
42+
[cljs.test-test]
43+
[static.core-test]))
4344

4445
(set! *print-newline* false)
4546
(set-print-fn! js/print)
@@ -76,4 +77,5 @@
7677
'cljs.predicates-test
7778
'cljs.syntax-quote-test
7879
'cljs.tagged-literals-test
79-
'cljs.test-test)
80+
'cljs.test-test
81+
'static.core-test)

src/test/self/self_parity/test.cljs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,8 @@
281281
[cljs.hash-map-test]
282282
[cljs.syntax-quote-test]
283283
[cljs.predicates-test]
284-
[cljs.test-test]))
284+
[cljs.test-test]
285+
[static.core-test]))
285286
(fn [{:keys [value error]}]
286287
(if error
287288
(prn error)
@@ -317,7 +318,8 @@
317318
'cljs.hash-map-test
318319
'cljs.syntax-quote-test
319320
'cljs.predicates-test
320-
'cljs.test-test)
321+
'cljs.test-test
322+
'static.core-test)
321323
(fn [{:keys [value error]}]
322324
(when error
323325
(prn error)))))))))

0 commit comments

Comments
 (0)