def shrinkify(assertion, data, depth=0, iteration=0)
io.puts "Shrinking at depth #{depth}:"
pretty_print data
min_data = data
max_depth = depth
if data.shrinkable?
while iteration < 1024 do
shrunk_data = data.shrink
begin
assertion.call(shrunk_data)
rescue Exception
branch_data, branch_depth, iteration = shrinkify(assertion, shrunk_data, depth + 1, iteration + 1)
if branch_depth > max_depth
min_data = branch_data
max_depth = branch_depth
end
end
break if !data.retry?
end
end
return min_data, max_depth, iteration
end