Using test.check, I'm finding the shrinking to be very, very slow. Running
a hundred cases takes a few seconds, unless it hits an error, in which case
it takes 40-60 minutes to shrink, and the shrinking is not very effective
(resulting test case is much larger than necessary). Sometimes the
shrinking is much faster. It behaves a bit like it's occasionally getting
into a pathological state, or a difficult shrinking scenario.
Are there any docs on generators or the shrinking algorithm that would help
build tests that shrink more effectively?
The problematic generator builds a randomly-sized matrix of integers, with
randomly assigned names for the rows and columns. The failure case is when
either a column or row name is repeated. I expect the slow shrinking has
something to do with it being rare for the generator to emit the same name
twice.
; Generator of randomly sized matrices of random numbers.
(def gen-matrix
(gen/bind
gen/s-pos-int
(fn [x] (gen/bind
gen/s-pos-int
(fn [y] (gen/vector (gen/vector gen/int x) y))))))
; Generator of matrix with probe and sample ids.
(def gen-tsv
(gen/bind
gen-matrix
(fn [m]
(gen/hash-map
:probes (gen/vector
(gen/such-that not-empty gen/string-alpha-numeric)
(count m))
:samples (gen/vector
(gen/such-that not-empty gen/string-alpha-numeric)
(count (first m)))
:matrix (gen/return m)))))
Shrinking will result in a case like
{:matrix [[1 4 -3] [-4 -3 -5] [-5 2 3] [4 -5 -5] [1 -2 3] [1 4 1]],
:samples ["0" "0" "0"], :probes ["0" "0" "0" "0" "0" "0"]}
where :samples ["0" "0"] :probes["0"] would do.
The following test will exhibit the behavior, sometimes succeeding,
sometimes failing quickly, sometimes shrinking for a very long time:
(tc/quick-check 100 (prop/for-all [tsv gen-tsv] (= (count (set (:probes
tsv))) (count (:probes tsv)))))
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
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 [email protected].
For more options, visit https://groups.google.com/d/optout.