File tree Expand file tree Collapse file tree 2 files changed +7
-11
lines changed Expand file tree Collapse file tree 2 files changed +7
-11
lines changed Original file line number Diff line number Diff line change 57
57
58
58
Returns a spec."
59
59
[form & {:keys [gen]}]
60
- `(cljs.spec/spec-impl '~(res &env form) ~form ~gen nil ))
60
+ (when form
61
+ `(cljs.spec/spec-impl '~(res &env form) ~form ~gen nil )))
61
62
62
63
(defmacro multi-spec
63
64
" Takes the name of a spec/predicate-returning multimethod and a
251
252
that returns a test.check generator."
252
253
[& {:keys [args ret fn gen]}]
253
254
(let [env &env]
254
- `(cljs.spec/fspec-impl ~args '~(res env args) ~ret '~(res env ret) ~fn '~(res env fn ) ~gen)))
255
+ `(cljs.spec/fspec-impl (spec ~args) '~(res env args)
256
+ (spec ~ret) '~(res env ret)
257
+ (spec ~fn) '~(res env fn ) ~gen)))
255
258
256
259
(defmacro tuple
257
260
" takes one or more preds and returns a spec for a tuple, a vector
Original file line number Diff line number Diff line change 1060
1060
(defn ^:skip-wiki fspec-impl
1061
1061
" Do not call this directly, use 'fspec'"
1062
1062
[argspec aform retspec rform fnspec fform gfn]
1063
- (assert (c/and argspec retspec))
1064
1063
(let [specs {:args argspec :ret retspec :fn fnspec}]
1065
1064
(reify
1066
1065
IFn
1067
1066
(-invoke [this x] (valid? this x))
1068
1067
ILookup
1069
- (-lookup [this k]
1070
- (-lookup this k nil ))
1071
- (-lookup [_ k not-found]
1072
- (case k
1073
- :args argspec
1074
- :ret retspec
1075
- :fn fnspec
1076
- not-found))
1068
+ (-lookup [this k] (get specs k))
1069
+ (-lookup [_ k not-found] (get specs k not-found))
1077
1070
Spec
1078
1071
(conform* [_ f] (if (fn? f)
1079
1072
(if (identical? f (validate-fn f specs *fspec-iterations*)) f ::invalid )
You can’t perform that action at this time.
0 commit comments