2 SchemeUnit Integration
This module provides the test-random macro for generating SchemeUnit
test suites that generate and record random inputs.
(test-random opt ... | ([lhs rhs bind-opt ...] | ...) | body ...+) |
|
|
opt | | = | | #:name name | | | | | | #:repeat repeat | | | | | | #:limit limit | | | | | | bind-opt | | = | | #:where bind-where | | | | | | #:limit bind-limit |
|
The
test-random form constructs a SchemeUnit
test-suite that
conducts multiple trials of
body ...+. During a trial, each variable
lhs is bound to the value of the corresponding expression
rhs.
Bindings proceed left-to-right with
let*-scope, and each
rhs
is re-run to permit new random values.
The suite conducts repeat trials (default 100).
After each rhs is run, its corresponding where expression (if
any) is run; if where evaluates to #t, the rhs is
re-run. Each rhs is run at most the minimum of limit and the
corresponding bind-limit, defaulting to 10000.
Examples: |
> (require (planet schematics/schemeunit:2:10/test) | (planet schematics/schemeunit:2:10/text-ui)) |
|
> (random-seed 1) |
|
100 success(es) 0 failure(s) 0 error(s) 100 test(s) run |
0 |
> (random-seed 1) |
|
| test w/ options > 1 | 1 has a FAILURE | x: -165 | y: 7 | name: check-pred | location: eval:119:0 | params: | #<procedure:positive?> | -158 | | test w/ options > 3 | 3 has a FAILURE | x: -688 | y: 37 | name: check-pred | location: eval:119:0 | params: | #<procedure:positive?> | -651 | | test w/ options > 5 | 5 has an ERROR | test w/ options: Out of random values. Failed attempts include: | | | | === context === | /Users/cce/Desktop/Racket v5.0.99.900/add-on/planet/5.0.99.900/cache/schematics/schemeunit.plt/2/12/plt/result.ss:70:5 | /Users/cce/Desktop/Racket v5.0.99.900/add-on/planet/5.0.99.900/cache/schematics/schemeunit.plt/2/12/plt/../generic/foldts.ss:57:6: loop | test/text-ui | /Users/cce/Desktop/Racket v5.0.99.900/collects/racket/private/more-scheme.rkt:149:2: call-with-break-parameterization | /Users/cce/Desktop/Racket v5.0.99.900/collects/racket/sandbox.rkt:727:9: loop | | | 2 success(es) 2 failure(s) 1 error(s) 5 test(s) run |
|
3 |
> (random-seed 1) |
|
| test w/ bind options > 3 | 3 has an ERROR | test w/ bind options: Out of random values. See trial #4 for list of attempts. | | === context === | /Users/cce/Desktop/Racket v5.0.99.900/add-on/planet/5.0.99.900/cache/schematics/schemeunit.plt/2/12/plt/result.ss:70:5 | /Users/cce/Desktop/Racket v5.0.99.900/add-on/planet/5.0.99.900/cache/schematics/schemeunit.plt/2/12/plt/../generic/foldts.ss:57:6: loop | test/text-ui | /Users/cce/Desktop/Racket v5.0.99.900/collects/racket/private/more-scheme.rkt:149:2: call-with-break-parameterization | /Users/cce/Desktop/Racket v5.0.99.900/collects/racket/sandbox.rkt:727:9: loop | | | | test w/ bind options > 4 | 4 has an ERROR | test w/ bind options: Out of random values. Failed attempts include: | | x = -123 | y = 2716 | | x = -123 | y = 886 | | x = -688 | | | === context === | /Users/cce/Desktop/Racket v5.0.99.900/add-on/planet/5.0.99.900/cache/schematics/schemeunit.plt/2/12/plt/result.ss:70:5 | /Users/cce/Desktop/Racket v5.0.99.900/add-on/planet/5.0.99.900/cache/schematics/schemeunit.plt/2/12/plt/../generic/foldts.ss:57:6: loop | test/text-ui | /Users/cce/Desktop/Racket v5.0.99.900/collects/racket/private/more-scheme.rkt:149:2: call-with-break-parameterization | /Users/cce/Desktop/Racket v5.0.99.900/collects/racket/sandbox.rkt:727:9: loop | | | 2 success(es) 0 failure(s) 2 error(s) 4 test(s) run |
|
2 |