File tree Expand file tree Collapse file tree 2 files changed +26
-29
lines changed Expand file tree Collapse file tree 2 files changed +26
-29
lines changed Original file line number Diff line number Diff line change @@ -142,10 +142,27 @@ Returns a collection of syms naming the vars unstrumented."
142
142
143
143
; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; testing ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
144
144
145
- (defmacro sym->check-map
146
- [[quote s]]
147
- (if-let [{:keys [name] :as v} (ana-api/resolve &env s)]
148
- `{:s '~s
149
- :v (var ~name)
150
- :spec (s/get-spec (var ~name))}
151
- `{:s '~s}))
145
+ (defmacro check-1
146
+ [[quote s] f opts]
147
+ (let [{:keys [name] :as v} (ana-api/resolve &env s)]
148
+ `(let [s# '~name
149
+ opts# ~opts
150
+ v# ~(when v `(var ~name))
151
+ spec# ~(when v `(s/get-spec (var ~name)))
152
+ re-inst?# (and v# (seq (unstrument '~name)) true )
153
+ f# (or ~f (when v# @v#))]
154
+ (try
155
+ (cond
156
+ (nil? f#)
157
+ {:failure (ex-info " No fn to spec" {::s/failure :no-fn })
158
+ :sym s# :spec spec#}
159
+
160
+ (:args spec#)
161
+ (let [tcret# (quick-check f# spec# opts#)]
162
+ (make-check-result s# spec# tcret#))
163
+
164
+ :default
165
+ {:failure (ex-info " No :args spec" {::s/failure :no-args-spec })
166
+ :sym s# :spec spec#})
167
+ (finally
168
+ (when re-inst?# (instrument '~name)))))))
Original file line number Diff line number Diff line change @@ -222,26 +222,6 @@ with explain-data + ::s/failure."
222
222
(when-let [shrunk (-> test-check-ret :shrunk )]
223
223
{:failure (:result shrunk)})))
224
224
225
- (defn- check-1
226
- [{:keys [s f v spec]} opts]
227
- (let [re-inst? (and v (seq (unstrument s)) true )
228
- f (or f (when v @v))]
229
- (try
230
- (cond
231
- (nil? f)
232
- {:failure (ex-info " No fn to spec" {::s/failure :no-fn })
233
- :sym s :spec spec}
234
-
235
- (:args spec)
236
- (let [tcret (quick-check f spec opts)]
237
- (make-check-result s spec tcret))
238
-
239
- :default
240
- {:failure (ex-info " No :args spec" {::s/failure :no-args-spec })
241
- :sym s :spec spec})
242
- (finally
243
- (when re-inst? (instrument s))))))
244
-
245
225
(defn- validate-check-opts
246
226
[opts]
247
227
(assert (every? ident? (keys (:gen opts))) " check :gen expects ident keys" ))
@@ -414,9 +394,9 @@ key with a count for each different :type of result."
414
394
([a b]
415
395
(ranged-rand 8 5 )))
416
396
(foo 1 2 )
417
- (m/unstrument-1 ranged-rand)
397
+ (m/unstrument-1 ` ranged-rand)
418
398
419
- (m/sym-> check-map ' ranged-rand)
399
+ (m/check-1 ` ranged-rand nil {} )
420
400
)
421
401
422
402
You can’t perform that action at this time.
0 commit comments