test.check's gen/pos-int currently returns 0.
Users of clojure.spec grabbing the generator for predicate c.c/pos-int? do not receive the 0 because spec filters generated values by the predicate:
user> (clojure.spec.gen.alpha/sample (clojure.spec.alpha/gen pos-int?))
(1 1 1 4 2 4 31 1 8 4)
user> (clojure.test.check.generators/sample clojure.test.check.generators/pos-int)
(0 0 1 1 0 5 1 2 1 4)
This seems like a bug in the underlying generator. Receiving 0 (probably) surprises users, but it's been like this forever.
There are at least these two options:
- Make a new corrected generator with a new name
- Correct the generator returned by gen/pos-int to never return 0, giving less cases to its users (spec users remain unaffected)
Does Rich's algebra of compatibility, namely functions providing less => breakage -- does that apply here? Changing the function returns a generator of random values - but one value would be missing.
(there's an old adage I'm butchering: eventually users rely on all program behaviors whether correct or not.)
--
You received this message because you are subscribed to the Google Groups "Clojure Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure-dev+unsubscribe@googlegroups.com.
To post to this group, send email to cloju...@googlegroups.com.
Visit this group at https://groups.google.com/group/clojure-dev.
For more options, visit https://groups.google.com/d/optout.