29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/pbt/arbitrary/array_arbitrary.rb', line 29
def shrink(current)
return Enumerator.new { |_| } if current.size == @min_length
Enumerator.new do |y|
@length_arb.shrink(current.size).each do |length|
if length == 0
y.yield []
next
end
current.each_cons(length) do |con|
y.yield con
end
end
current.each_with_index do |item, i|
@value_arb.shrink(item).each do |val|
y.yield [*current[...i], val, *current[i + 1..]]
end
end
end
end
|