Module: RushCheck::Testable

Included in:
FalseClass, NilClass, RandomProc, Assertion, Claim, Property, Result, TrueClass
Defined in:
lib/rushcheck/testable.rb

Instance Method Summary collapse

Instance Method Details

#check(config = RushCheck::Config.new) ⇒ Object Also known as: quick_check, quickcheck



17
18
19
# File 'lib/rushcheck/testable.rb', line 17

def check(config=RushCheck::Config.new)
  config.tests(property.gen, RushCheck::TheStdGen.instance)
end

#classify(name) ⇒ Object



23
24
25
# File 'lib/rushcheck/testable.rb', line 23

def classify(name)
  yield ? label(name) : property
end

#implyObject



27
28
29
# File 'lib/rushcheck/testable.rb', line 27

def imply
  yield ? property : RushCheck::Result.nothing.result
end

#label(s) ⇒ Object Also known as: collect



31
32
33
# File 'lib/rushcheck/testable.rb', line 31

def label(s)
  RushCheck::Property.new(property.gen.fmap {|res| res.stamp << s.to_s; res })
end

#propertyObject

Raises:

  • (NotImplementedError)


13
14
15
# File 'lib/rushcheck/testable.rb', line 13

def property
  raise(NotImplementedError, "This method should be overrided.")    
end

#run(opts) ⇒ Object



36
37
38
39
# File 'lib/rushcheck/testable.rb', line 36

def run(opts)
  RushCheck::Config.batch(opts.ntests, opts.debug?).
    tests_batch(property, RushCheck::StdGen.new(0))
end

#run_tests(name, opts, tests) ⇒ Object



93
94
95
96
97
98
# File 'lib/rushcheck/testable.rb', line 93

def run_tests(name, opts, tests)
  print(rjustify(25, name) + " : ")
  f = try_test(tests)
  f.each { |f, n, no| final_run(f, n, no, name) }
  nil
end

#silent_checkObject



100
101
102
# File 'lib/rushcheck/testable.rb', line 100

def silent_check
  check(RushCheck::Config.silent)
end

#testObject Also known as: verbose_check



104
105
106
# File 'lib/rushcheck/testable.rb', line 104

def test
  check(RushCheck::Config.verbose)
end

#testcaseObject



109
110
111
# File 'lib/rushcheck/testable.rb', line 109

def testcase
  Proc.new {|opts| run(opts)}
end

#trivialObject



113
114
115
# File 'lib/rushcheck/testable.rb', line 113

def trivial
  classify('trivial') { yield }
end