-
Notifications
You must be signed in to change notification settings - Fork 8
Description
This is related to #21, which helped me trace to clojurescript 1.10.520.
ISSUE
when using clojurescript > 1.10.520, generating for any non-primitive schema seems to fail with
> (g/sample 10 {:a s/Str})
The result object failed to print. It is available via *1 if you want to interact with it.
The exception was:
#error {:message "Couldn't satisfy such-that predicate after 10 tries.", :data {:pred #object[G__31076], :gen #clojure.test.check.generators.Generator{:gen #object[Function]}, :max-tries 10}}
generating for primitives works as expected
cljs.user=> (g/sample 10 s/Str)
("" "" "" "(" "|" "s" "BdB" "or@nPC" "3nFU" "yTVJ}a")
REPRO
https://github.com/whacked/sg-issue-repro
- note that for clojurescript 1.10.773, the error is printed to the REPL
- for 1.10.597, it is printed to the host's console and not the REPL
workaround
based on #21 I have verified that this issue disappears when building with clojurescript 1.10.520. This is achieved by pulling npm install [email protected]
, which declares clojurescript 1.10.520
as a dependency. [email protected]
declares 1.10.597
which begins exhibiting this issue.
other notes
I did a very quick check directly against clojure.test.check.random
based on your comment in #21 (comment)
> (require '[clojure.test.check.generators :as gen])
> (gen/sample gen/large-integer)
(0 -1 -1 -1 0 -13 4 12 5 1)
> (gen/sample gen/double)
(-0.5 2 1 0.5625 -0.5 -1.75 -3 0.76171875 -2.5 0.25)
I didn't dig much deeper than this, but when using the 10-sample default for test.check
generators, there's very high bias for 0 and -1, for example,
(->> (repeatedly (partial gen/sample gen/large-integer))
(take 100) # generate 100 rounds of 10 large-integers per sampling
(apply concat)
(frequencies)
(map (comp vec reverse))
(sort)
(take-last 10)
(map (comp vec reverse))
(cljs.pprint/pprint))
([6 11]
[-5 12]
[2 23]
[-4 29]
[-3 33]
[3 38]
[-2 72]
[1 82]
[-1 244]
[0 261])
So this could be related to the repeated random values that you point out in the comment, but the test.check dependency doesn't change across shadow 2.8.72 and 2.8.72, so perhaps the root cause is elsewhere.