Class: PropCheck::Property::Shrinker

Inherits:
Object
  • Object
show all
Defined in:
lib/prop_check/property/shrinker.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bindings_tree, io, hooks, config) ⇒ Shrinker

Returns a new instance of Shrinker.



3
4
5
6
7
8
9
10
11
12
# File 'lib/prop_check/property/shrinker.rb', line 3

def initialize(bindings_tree, io, hooks, config)
  @problem_child = bindings_tree
  @io = io
  @siblings = @problem_child.children.lazy
  @parent_siblings = nil
  @problem_exception = nil
  @shrink_steps = 0
  @hooks = hooks
  @config = config
end

Class Method Details

.call(bindings_tree, io, hooks, config, &block) ⇒ Object



14
15
16
17
18
# File 'lib/prop_check/property/shrinker.rb', line 14

def self.call(bindings_tree, io, hooks, config, &block)
  self
    .new(bindings_tree, io, hooks, config)
    .call(&block)
end

Instance Method Details

#call(&block) ⇒ Object



20
21
22
23
24
25
26
27
28
# File 'lib/prop_check/property/shrinker.rb', line 20

def call(&block)
  @io.puts 'Shrinking...' if @config.verbose

  shrink(&block)

  print_shrinking_exceeded_message if @shrink_steps >= @config.max_shrink_steps

  [@problem_child.root, @problem_exception, @shrink_steps]
end