On Thursday, June 2, 2016 at 8:57:24 PM UTC-5, Gary Fredericks wrote: > > The generator should definitely always generate unique values (though only > because gen/uuid does that), though as you say shrinking is different > case that would be problematic for what you're doing. When you say "I don't > see any other error" have you accounted for the fact that test.check > normally returns *two* results after shrinking (the first failure, and > the final failure)? This could be especially difficult to notice if the > first failure was not an exception, and is being reported as merely false > while the stacktrace of the final failure takes up your whole screen. > > To be more precise, the original failure is under the :result key of the > test.check result, while all the shrinking info is under :shrunk > (including another :result key). >
Ah OK. I didn't know this. Thanks, I'll take a look. > > Other than that I don't have any ideas, but you should be able to check > your theory about for-all reusing generated values by collecting them in an > atom or something like that. > Yup. I was hoping to avoid this, but seems like I'll have to. > > Gary > > On Thursday, June 2, 2016 at 9:51:46 AM UTC-5, Tom wrote: >> >> Hi, >> >> I'm doing something like: >> >> (def valid-email (gen/fmap (fn [[name domain]] (str name "@" domain)) >> (gen/tuple (gen/not-empty gen/string) gen/uuid))) >> >> (defspec test-email >> 100 >> (for-all [email valid-email] >> (tx-email! (get-in system [:database :conn]) email) >> >> The email has a unique-by-value constraint (in datomic) and this >> transaction fails occasionally because the unique-by-value constraint >> fails. However, this: >> >> (= 1000 (count (distinct (gen/sample valid-email 1000)))) >> >> always succeeds. It seems like for-all reuses a generated value >> sometimes. Could this be possible? Or maybe this happens when test.check >> tries to shrink the test case? Except I don't see any other error, one that >> would cause it to try to shrink. >> >> Thanks. >> >> -Tom >> >> -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.