Skip to content

Commit

Permalink
CLJS-1657: Self-host: Implicit macro loading with alias
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
anmonteiro authored and swannodette committed Aug 15, 2016
1 parent 63e0d73 commit bc7f1d4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
24 changes: 23 additions & 1 deletion src/test/self/self_host/test.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@

(deftest test-load-and-invoke-macros
(async done
(let [l (latch 11 done)]
(let [l (latch 12 done)]
;; Normal require macros
(let [st (cljs/empty-state)]
(cljs/eval-str st
Expand Down Expand Up @@ -590,6 +590,28 @@
(fn [{:keys [error value]}]
(is (nil? error))
(is (= 320 value))
(inc! l))))))
(let [st (cljs/empty-state)]
;; Rely on implicit macro loading (ns loads its own macros), with an alias
;; CLJS-1657
(cljs/eval-str st
"(ns cljs.user (:require [foo.core :as foo]))"
nil
{:eval node-eval
:load (fn [{:keys [macros]} cb]
(if macros
(cb {:lang :clj :source "(ns foo.core) (defmacro add [a b] `(+ ~a ~b))"})
(cb {:lang :clj :source "(ns foo.core (:require-macros foo.core))"})))}
(fn [{:keys [value error]}]
(is (nil? error))
(cljs/eval-str st
"(foo/add 300 500)"
nil
{:eval node-eval
:context :expr}
(fn [{:keys [error value]}]
(is (nil? error))
(is (= 800 value))
(inc! l)))))))))

(deftest test-eval-str-with-require-macros
Expand Down
10 changes: 1 addition & 9 deletions src/test/self/self_parity/test.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -230,23 +230,15 @@
:verbose false}
cb))

(defn prime-analysis-cache-for-implicit-macro-loading
"Supports priming analysis cache in order to work around
http://dev.clojure.org/jira/browse/CLJS-1657"
[st ns-sym]
(swap! st assoc-in [::cljs.analyzer/namespaces ns-sym :require-macros] {ns-sym ns-sym}))

;; Test suite runner

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

0 comments on commit bc7f1d4

Please sign in to comment.