borkdude / speculative

Unofficial community-driven specs for clojure.core
Eclipse Public License 1.0
188 stars 16 forks source link

assoc-in #179

Closed bonega closed 5 years ago

bonega commented 5 years ago

Generative testing would need specs using multimethod on type I think. In case of a vector or another non-sparse associative only integers (<= 0 % (count coll)) is valid. I have not implemented that, is that in the scope for speculative?

borkdude commented 5 years ago

@bonega If you like the challenge, you can look at what I did for generative testing of into and conj: you can override the generators. So you can write one generative test for the vector case and one for all other associatives (I think it only generates vectors and maps at the moment). If you don't like that work, I'm happy to take it further.

borkdude commented 5 years ago

@bonega I just wrote the generator for the assoc arguments here: https://github.com/slipset/speculative/blob/master/src/speculative/core.cljc#L67 Extending this to assoc-in should be relatively easy now I hope: the only challenge is to generate nested vectors. It's still optional as far as I'm concerned.

Could you add some (is (caught? ...)) checks to the test to verify that the spec catches cases like (assoc-in 1 1 1)?