Next: , Previous: , Up: API  


1.13 (veritas property)

Properties: one assertion, many generated inputs. A property draws a value from each of its generators, calls its thunk, and repeats; a thunk that fails for one input makes the property fail, and the failing input is shrunk to the smallest value that still fails before it is reported. The seed is reported too, so a failure can be replayed with VERITAS_SEED.

1.13.1 Procedures

Procedure: property name KEY: #:generators #:thunk #:runs #:seed #:shrink?

Return a property named name, a task like a test.

generators is a non-empty list of generators, one per argument of thunk. Each of the runs runs draws one value from every generator and calls the thunk with them; the thunk returns the assertions to check, as a test body does.

(property \"reverse of reverse is the original list\"
          #:generators (list (generate-list (generate-integer)))
          #:thunk (lambda (xs)
                    (assert-equal #:expect xs
                                  #:got (reverse (reverse xs)))))

A failing input is shrunk to the smallest value from the same generators that still fails, and both values are reported. seed makes the draw reproducible; without one, VERITAS_SEED is used, and failing that a fresh seed is drawn and reported with the failure.