Module: Forall::Matchers

Defined in:
lib/forall/matchers.rb

Defined Under Namespace

Classes: ForallMatcher

Instance Method Summary collapse

Instance Method Details

#exhaustive(input) ⇒ Object



24
25
26
# File 'lib/forall/matchers.rb', line 24

def exhaustive(input)
  Input.exhaustive(input)
end

#forall(input) ⇒ Object

@example:

describe "foo" do
  forall([1,2,3]).check                 {|x,c| c.skip if x.even?; (x*2+1).even? }
  forall(...).check(seed: 999)          {|x,c| c.skip if x.even?; (x*2+1).even? }
  forall(...).check(success_limit: 50)  {|x,c| c.skip if x.even?; (x*2+1).even? }
  forall(...).check(discard_limit: 0.10){|x,c| c.skip if x.even?; (x*2+1).even? }
  forall(...).check(shrink_limit: 10)   {|x,c| c.skip if x.even?; (x*2+1).even? }

  forall(lambda{|rnd, x| rnd.integer(x)}).
    check(0..9){|x,_| x.between?(0,9)}
end


16
17
18
# File 'lib/forall/matchers.rb', line 16

def forall(input)
  ForallMatcher.new(input)
end

#sampled(input = nil, &block) ⇒ Object



20
21
22
# File 'lib/forall/matchers.rb', line 20

def sampled(input = nil, &block)
  Input.sampled(input || block)
end