[spec] Include spec name in Generator.toString to help troubleshooting "Couldn't satisfy such-that .."

Description

As of Spec 0.2.176, when test.check cannot generate a suitable value, it fails with a rather useless error message that does not point to the thing it was trying to generate:

ExecutionException: clojure.lang.ExceptionInfo: Couldn't satisfy such-that predicate after 100 tries. {red #object[clojure.spec.alpha$gensub$fn_1876 0x669d7a6a "clojure.spec.alpha$gensub$fn1876@669d7a6a"], :gen #clojure.test.check.generators.Generator{:gen #object[clojure.test.check.generators$such_that$fn1111 0x5fc56c81 "clojure.test.check.generators$such_that$fn_1111@5fc56c81"]}, :max-tries 100}

It would be I believe much better if the generator created by (s/gen ::myspec) somehow included the ::myspec name so that it would print out something like

{#clojure.test.check.generators.Generator{
:gen #object[clojure.test.check.generators$such_that$fn__1111 0x5fc56c81 ":my.ns/myspec"]}}

(Notice the `.toString` of the generated generator has been modified to print the spec name: ":my.ns/myspec"; though perhaps "gen for :my.ns/myspec" would be clearer.)

Environment

None

Activity

Show:

Details

Assignee

Reporter

Approval

Triaged

Priority

Created May 23, 2019 at 7:27 AM
Updated June 3, 2019 at 1:41 PM