Skip to content

Commit f48d6ec

Browse files
committed
implement checkable-syms
1 parent 03a7c20 commit f48d6ec

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

src/main/cljs/cljs/spec/test.cljc

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
(list x)
2222
x))
2323

24+
(defn- fn-spec-name?
25+
[s]
26+
(symbol? s))
27+
2428
(defmacro enumerate-namespace
2529
"Given a symbol naming an ns, or a collection of such symbols,
2630
returns the set of all symbols naming vars in those nses."
@@ -175,4 +179,16 @@ Returns a collection of syms naming the vars unstrumented."
175179
([f spec opts]
176180
`(let [opts# ~opts]
177181
(validate-check-opts opts#)
178-
(check-1 nil ~f ~spec opts#))))
182+
(check-1 nil ~f ~spec opts#))))
183+
184+
(defmacro checkable-syms
185+
"Given an opts map as per check, returns the set of syms that
186+
can be checked."
187+
([]
188+
`(checkable-syms nil))
189+
([opts]
190+
`(let [opts# ~opts]
191+
(validate-check-opts opts#)
192+
(reduce conj #{}
193+
'[~@(filter fn-spec-name? (keys @s/registry-ref))
194+
~@(keys (:spec opts))]))))

src/main/cljs/cljs/spec/test.cljs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -226,15 +226,6 @@ with explain-data + ::s/failure."
226226
[opts]
227227
(assert (every? ident? (keys (:gen opts))) "check :gen expects ident keys"))
228228

229-
(defn checkable-syms
230-
"Given an opts map as per check, returns the set of syms that
231-
can be checked."
232-
([] (checkable-syms nil))
233-
([opts]
234-
(validate-check-opts opts)
235-
(reduce into #{} [(filter fn-spec-name? (keys (s/registry)))
236-
(keys (:spec opts))])))
237-
238229
(defn check
239230
"Run generative tests for spec conformance on vars named by
240231
sym-or-syms, a symbol or collection of symbols. If sym-or-syms
@@ -394,6 +385,8 @@ key with a count for each different :type of result."
394385
(s/fspec
395386
:args (s/cat :x int?)
396387
:ret int?))
388+
389+
(m/checkable-syms)
397390
)
398391

399392

0 commit comments

Comments
 (0)