Class: RushCheck::Assertion
- Inherits:
-
Object
- Object
- RushCheck::Assertion
- Includes:
- Testable
- Defined in:
- lib/rushcheck/assertion.rb
Overview
Assertion class is one of main features of RushCheck. You can write a testcase for random testing as follows:
Assertion.new(Integer, String) do |x, y|
RushCheck::guard { precondition }
body
end
The return value of the body of testcase is checked by the method ‘check’.
Note that the number of arguments in the block must be equal to the number of arguments of Assertion.new. However, for a curried block, we can write also
Assertion.new(*cs) {|*xs| ...}
See also class Claim, which is a subclass of Assertion See also the RushCheck tutorial and several examples.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#proc ⇒ Object
readonly
Returns the value of attribute proc.
Instance Method Summary collapse
-
#initialize(*xs, &f) ⇒ Assertion
constructor
A new instance of Assertion.
- #property ⇒ Object
Methods included from Testable
#check, #classify, #imply, #label, #run, #run_tests, #silent_check, #test, #testcase, #trivial
Constructor Details
#initialize(*xs, &f) ⇒ Assertion
Returns a new instance of Assertion.
37 38 39 40 |
# File 'lib/rushcheck/assertion.rb', line 37 def initialize(*xs, &f) @inputs = xs[0..(f.arity - 1)] @proc = f end |
Instance Attribute Details
#proc ⇒ Object (readonly)
Returns the value of attribute proc.
35 36 37 |
# File 'lib/rushcheck/assertion.rb', line 35 def proc @proc end |