File tree Expand file tree Collapse file tree 2 files changed +24
-17
lines changed Expand file tree Collapse file tree 2 files changed +24
-17
lines changed Original file line number Diff line number Diff line change @@ -143,12 +143,12 @@ Returns a collection of syms naming the vars unstrumented."
143
143
; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; testing ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
144
144
145
145
(defmacro check-1
146
- [[quote s] f opts]
147
- (let [{:keys [name] :as v} (ana-api/resolve &env s)]
146
+ [[quote s :as qs ] f spec opts]
147
+ (let [{:keys [name] :as v} (when qs ( ana-api/resolve &env s) )]
148
148
`(let [s# '~name
149
149
opts# ~opts
150
150
v# ~(when v `(var ~name))
151
- spec# ~ (when v `(s/get-spec (var ~name)))
151
+ spec# ( or ~spec ~ (when v `(s/get-spec (var ~name) )))
152
152
re-inst?# (and v# (seq (unstrument '~name)) true )
153
153
f# (or ~f (when v# @v#))]
154
154
(try
@@ -165,4 +165,14 @@ Returns a collection of syms naming the vars unstrumented."
165
165
{:failure (ex-info " No :args spec" {::s/failure :no-args-spec })
166
166
:sym s# :spec spec#})
167
167
(finally
168
- (when re-inst?# (instrument '~name)))))))
168
+ (when re-inst?# (instrument '~name)))))))
169
+
170
+ (defmacro check-fn
171
+ " Runs generative tests for fn f using spec and opts. See
172
+ 'check' for options and return."
173
+ ([f spec]
174
+ `(check-fn ~f ~spec nil ))
175
+ ([f spec opts]
176
+ `(let [opts# ~opts]
177
+ (validate-check-opts opts#)
178
+ (check-1 nil ~f ~spec opts#))))
Original file line number Diff line number Diff line change @@ -226,14 +226,6 @@ with explain-data + ::s/failure."
226
226
[opts]
227
227
(assert (every? ident? (keys (:gen opts))) " check :gen expects ident keys" ))
228
228
229
- (defn check-fn
230
- " Runs generative tests for fn f using spec and opts. See
231
- 'check' for options and return."
232
- ([f spec] (check-fn f spec nil ))
233
- ([f spec opts]
234
- (validate-check-opts opts)
235
- (check-1 {:f f :spec spec} opts)))
236
-
237
229
(defn checkable-syms
238
230
" Given an opts map as per check, returns the set of syms that
239
231
can be checked."
@@ -370,10 +362,10 @@ key with a count for each different :type of result."
370
362
371
363
(s/fdef ranged-rand
372
364
:args (s/and (s/cat :start int? :end int?)
373
- #(< (:start %) (:end %)))
374
- :ret int?
375
- :fn (s/and #(>= (:ret %) (-> % :args :start ))
376
- #(< (:ret %) (-> % :args :end ))))
365
+ #(< (:start %) (:end %)))
366
+ :ret int?
367
+ :fn (s/and #(>= (:ret %) (-> % :args :start ))
368
+ #(< (:ret %) (-> % :args :end ))))
377
369
378
370
(instrumentable-syms )
379
371
@@ -396,7 +388,12 @@ key with a count for each different :type of result."
396
388
(foo 1 2 )
397
389
(m/unstrument-1 `ranged-rand)
398
390
399
- (m/check-1 `ranged-rand nil {})
391
+ (m/check-1 `ranged-rand nil nil {})
392
+
393
+ (m/check-fn inc
394
+ (s/fspec
395
+ :args (s/cat :x int?)
396
+ :ret int?))
400
397
)
401
398
402
399
You can’t perform that action at this time.
0 commit comments