1313 [cljs.spec :as s]
1414 [cljs.spec.impl.gen :as gen]))
1515
16+ (defn- collectionize
17+ [x]
18+ (if (symbol? x)
19+ (list x)
20+ x))
21+
22+ (defmacro enumerate-namespace
23+ " Given a symbol naming an ns, or a collection of such symbols,
24+ returns the set of all symbols naming vars in those nses."
25+ [[quote ns-sym-or-syms]]
26+ (let [xs (into #{}
27+ (mapcat (fn [ns-sym]
28+ (->> (vals (ana-api/ns-interns ns-sym))
29+ (filter #(not (:macro %)))
30+ (map :name )
31+ (map
32+ (fn [name-sym]
33+ (symbol (name ns-sym) (name name-sym)))))))
34+ (collectionize ns-sym-or-syms))]
35+ `(quote ~xs)))
36+
1637(defmacro with-instrument-disabled
1738 " Disables instrument's checking of calls, within a scope."
1839 [& body]
@@ -77,13 +98,14 @@ Returns a collection of syms naming the vars instrumented."
7798 ([sym-or-syms]
7899 `(instrument ~sym-or-syms nil ))
79100 ([sym-or-syms opts]
80- `(into
81- []
82- (comp (filter (instrumentable-syms opts))
83- (distinct )
84- (map #(instrument-1* % opts))
85- (remove nil?))
86- (collectionize sym-or-syms))))
101+ `(let [opts# ~opts]
102+ (into
103+ []
104+ (comp (filter (instrumentable-syms opts#))
105+ (distinct )
106+ (map #(instrument-1* % opts#))
107+ (remove nil?))
108+ (collectionize ~sym-or-syms)))))
87109
88110(defmacro unstrument
89111 " Undoes instrument on the vars named by sym-or-syms, specified
@@ -93,11 +115,11 @@ Returns a collection of syms naming the vars unstrumented."
93115 `(unstrument (map ->sym (keys @instrumented-vars))))
94116 ([sym-or-syms]
95117 `(into
96- []
97- (comp (filter symbol?)
98- (map unstrument-1*)
99- (remove nil?))
100- (collectionize sym-or-syms))))
118+ []
119+ (comp (filter symbol?)
120+ (map unstrument-1*)
121+ (remove nil?))
122+ (collectionize ~ sym-or-syms))))
101123
102124(defmacro run-tests
103125 " Like run-all-tests, but scoped to specific namespaces, or to
0 commit comments