Closed cemerick closed 11 years ago
FYI, what I thought must have been an infinite loop bug in shrink-loop
disappeared once I started using the vector-gen
above, avoiding shrink-seq
.
I think it might make sense to cap total-nodes-visited
at some reasonable large number by default so that borked shrinker impls don't create runaways.
It's a little tough to see, but the shrinking is working how I intended. Whether that's correct or not is also up for debate though. First, it's important to view shrinking as a tree, the shrink
function which returns a sequence of shrinks only returns one level of the tree. Each of those children can then be shrunk more. So let's take a walk down the left-hand side of the tree:
(def starting [4502 382 714 4866 3339])
(first (gen/shrink genvec starting))
;; => [382 714 4866 3339]
(first (gen/shrink genvec *1))
;; => [714 4866 3339]
(first (gen/shrink genvec *1))
;; => [4866 3339]
(first (gen/shrink genvec *1))
;; => [3339]
(first (gen/shrink genvec *1))
;; => []
Going down the left-hand side of the tree is interesting because we'll keep going deeper in the tree as long as the test continues to fail. All of this being said, I think it's definitely worth comparing the performance/effectiveness of different shrink sequence generators.
I think it might make sense to cap total-nodes-visited at some reasonable large number by default so that borked shrinker impls don't create runaways.
+1. Perhaps a metric based on time too.
Created #9 to track shrink time-capping.
Here's the vector generator I'm using at the moment:
Seems more sane…?