Skip to content

Commit 9a7cdbe

Browse files
author
dnolen
committed
fspec gen ignores :fn rather than not gen.
same as Clojure aa9b5677
1 parent 87c542d commit 9a7cdbe

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/main/cljs/cljs/spec.cljc

+4
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,10 @@
263263
See 'fdef' for a single operation that creates an fspec and
264264
registers it, as well as a full description of :args, :ret and :fn
265265
266+
fspecs can generate functions that validate the arguments and
267+
fabricate a return value compliant with the :ret spec, ignoring
268+
the :fn spec if present.
269+
266270
Optionally takes :gen generator-fn, which must be a fn of no args
267271
that returns a test.check generator."
268272
[& {:keys [args ret fn gen]}]

src/main/cljs/cljs/spec.cljs

+4-5
Original file line numberDiff line numberDiff line change
@@ -1075,11 +1075,10 @@
10751075
{path {:pred 'ifn? :val f :via via :in in}}))
10761076
(gen* [_ _ _ _] (if gfn
10771077
(gfn)
1078-
(when-not fnspec
1079-
(gen/return
1080-
(fn [& args]
1081-
(assert (valid? argspec args) (with-out-str (explain argspec args)))
1082-
(gen/generate (gen retspec)))))))
1078+
(gen/return
1079+
(fn [& args]
1080+
(assert (valid? argspec args) (with-out-str (explain argspec args)))
1081+
(gen/generate (gen retspec))))))
10831082
(with-gen* [_ gfn] (fspec-impl argspec aform retspec rform fnspec fform gfn))
10841083
(describe* [_] `(fspec :args ~aform :ret ~rform :fn ~fform)))))
10851084

0 commit comments

Comments
 (0)