We're updating the issue view to help you get more done. 

instrumented fdef with fspec unnecessarily invokes fspec generator

Description

With test.check is on the classpath, an instrumented fdef with fspec will invoke the generator for the fspec when invoked:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 (require '[clojure.spec :as s] '[clojure.spec.test :as st]) (defn foo [fnn] (fnn 42)) (s/fdef foo :args (s/cat :f (s/fspec :args (s/cat :i integer?) :ret integer?))) (foo #(do (println %) (when (even? %) 42))) 42 42 (st/instrument `foo) (foo #(do (println %) (when (even? %) 42))) -1 0 -1 0 0 -1 0 -1 ExceptionInfo Call to #'user/foo did not conform to spec: In: [0] val: nil fails at: [:args :f :ret] predicate: integer? :clojure.spec/args (#object[user$eval12$fn__13 0x515c6049 "user$eval12$fn__13@515c6049"]) :clojure.spec/failure :instrument :clojure.spec.test/caller {:file "NO_SOURCE_FILE", :line 8, :var-scope user/eval12} clojure.core/ex-info (core.clj:4725)

Without test.check, this fails:

1 2 user=> (foo #(do (println %) (when (even? %) 42))) FileNotFoundException Could not locate clojure/test/check/generators__init.class or clojure/test/check/generators.clj on classpath. clojure.lang.RT.load (RT.java:458)

Environment

None

Status

Assignee

Unassigned

Reporter

Allen Rohner

Labels

Approval

Triaged

Patch

None

Affects versions

Release 1.9

Priority

Major