Class: Quick::Sampler::Base
- Inherits:
-
Enumerator::Lazy
- Object
- Enumerator::Lazy
- Quick::Sampler::Base
- Defined in:
- lib/quick/sampler/base.rb
Overview
A sampler base class, delegating most work to the underlying lazy enumerator.
Readable #inspect
One superficial extra that Base provides is a description attribute
which is returned by #inspect
. This can help keep test output readable.
Shrinking
Sampler::Base also provides an api for shrinking failed inputs.
From stackoverflow discussion of shrinking (follow the link for an example) in the original QuickCheck:
When QuickCheck finds an input that violates a property, it will first try to find smaller inputs that also violate the property, in order to give the developer a better message about the nature of the failure.
What it means to be „small“ of course depends on the datatype in question; to QuickCheck it is anything that comes out from from the shrink function.
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
Instance Method Summary collapse
-
#initialize(source, description: "Quick Sampler") ⇒ Base
constructor
private
Not supposed to be used directly, use compile instead.
-
#inspect ⇒ String
Sampler description, so test output is readable.
-
#shrink(samples) {|sample| ... } ⇒ Array
A very preliminary API for QuickCheck-like input shrinking.
Constructor Details
#initialize(source, description: "Quick Sampler") ⇒ Base
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Not supposed to be used directly, use Quick::Sampler.compile instead.
37 38 39 40 |
# File 'lib/quick/sampler/base.rb', line 37 def initialize source, description: "Quick Sampler" @description = description super(source_to_lazy(source)) end |
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
28 29 30 |
# File 'lib/quick/sampler/base.rb', line 28 def description @description end |
Instance Method Details
#inspect ⇒ String
Returns sampler description, so test output is readable.
43 44 45 |
# File 'lib/quick/sampler/base.rb', line 43 def inspect description end |