Skip to content

Commit bc7f1d4

Browse files
anmonteiroswannodette
authored andcommitted
CLJS-1657: Self-host: Implicit macro loading with alias
the issue is no longer reproducible given recent enhancements. In any case, added a unit test that checks for possible future regressions. As per the feedback in JIRA, removed the workaround for this issue in self parity tests.
1 parent 63e0d73 commit bc7f1d4

File tree

2 files changed

+24
-10
lines changed

2 files changed

+24
-10
lines changed

Diff for: src/test/self/self_host/test.cljs

+23-1
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@
371371

372372
(deftest test-load-and-invoke-macros
373373
(async done
374-
(let [l (latch 11 done)]
374+
(let [l (latch 12 done)]
375375
;; Normal require macros
376376
(let [st (cljs/empty-state)]
377377
(cljs/eval-str st
@@ -590,6 +590,28 @@
590590
(fn [{:keys [error value]}]
591591
(is (nil? error))
592592
(is (= 320 value))
593+
(inc! l))))))
594+
(let [st (cljs/empty-state)]
595+
;; Rely on implicit macro loading (ns loads its own macros), with an alias
596+
;; CLJS-1657
597+
(cljs/eval-str st
598+
"(ns cljs.user (:require [foo.core :as foo]))"
599+
nil
600+
{:eval node-eval
601+
:load (fn [{:keys [macros]} cb]
602+
(if macros
603+
(cb {:lang :clj :source "(ns foo.core) (defmacro add [a b] `(+ ~a ~b))"})
604+
(cb {:lang :clj :source "(ns foo.core (:require-macros foo.core))"})))}
605+
(fn [{:keys [value error]}]
606+
(is (nil? error))
607+
(cljs/eval-str st
608+
"(foo/add 300 500)"
609+
nil
610+
{:eval node-eval
611+
:context :expr}
612+
(fn [{:keys [error value]}]
613+
(is (nil? error))
614+
(is (= 800 value))
593615
(inc! l)))))))))
594616

595617
(deftest test-eval-str-with-require-macros

Diff for: src/test/self/self_parity/test.cljs

+1-9
Original file line numberDiff line numberDiff line change
@@ -230,23 +230,15 @@
230230
:verbose false}
231231
cb))
232232

233-
(defn prime-analysis-cache-for-implicit-macro-loading
234-
"Supports priming analysis cache in order to work around
235-
http://dev.clojure.org/jira/browse/CLJS-1657"
236-
[st ns-sym]
237-
(swap! st assoc-in [::cljs.analyzer/namespaces ns-sym :require-macros] {ns-sym ns-sym}))
238-
239233
;; Test suite runner
240234

241-
(defn run-tests
235+
(defn run-tests
242236
"Runs the tests."
243237
[]
244238
;; Ideally we'd just load test_runner.cljs, but a few namespace tests
245239
;; don't yet run in bootstrapped ClojureScript. These are commented
246240
;; out below and can be uncommented as fixed.
247241
(let [st (cljs/empty-state)]
248-
(prime-analysis-cache-for-implicit-macro-loading st 'cljs.spec)
249-
(prime-analysis-cache-for-implicit-macro-loading st 'cljs.spec.impl.gen)
250242
(eval-form st 'cljs.user
251243
'(ns parity.core
252244
(:require [cljs.test :refer-macros [run-tests]]

0 commit comments

Comments
 (0)