diff options
| author | 2025-02-14 17:19:07 -0500 | |
|---|---|---|
| committer | 2025-02-14 17:19:07 -0500 | |
| commit | b0921e1e41fe60012beda41c1e6e0087b47ba2cb (patch) | |
| tree | 95c2b86b9bb89023c0546d0ce0bb11855c6ff987 /srfi-252.sld | |
| parent | separate generators into different library (diff) | |
add error check to property test, and replace iota with a do loop
Diffstat (limited to 'srfi-252.sld')
| -rw-r--r-- | srfi-252.sld | 53 |
1 files changed, 28 insertions, 25 deletions
diff --git a/srfi-252.sld b/srfi-252.sld index b4227c1..6d9f426 100644 --- a/srfi-252.sld +++ b/srfi-252.sld @@ -25,7 +25,6 @@ (define-library (srfi 252) (import (scheme base) (scheme case-lambda) - (srfi 1) (srfi 64) (srfi 252 generators) (chicken condition)) @@ -58,31 +57,35 @@ (define property-test-runner test-runner-create) ;; Test procedures (define (prop-test property generators runs) - (for-each - (lambda (n) - (test-assert - (apply property - (let ((args (map (lambda (gen) (gen)) generators)) - (runner (test-runner-current))) - (test-result-set! runner 'property-test-arguments args) - (test-result-set! runner 'property-test-iteration - (+ n 1)) - (test-result-set! runner 'property-test-iterations runs) - args)))) - (iota runs))) + (unless (and (integer? runs) + (not (negative? runs))) + (error "runs must be a non-negative integer" runs)) + (do ((n 0 (+ n 1))) + ((= n runs)) + (test-assert + (apply property + (let ((args (map (lambda (gen) (gen)) generators)) + (runner (test-runner-current))) + (test-result-set! runner 'property-test-arguments args) + (test-result-set! runner 'property-test-iteration + (+ n 1)) + (test-result-set! runner 'property-test-iterations runs) + args))))) (define (prop-test-error type property generators runs) - (for-each - (lambda (n) - (test-error - type - (apply property - (let ((args (map (lambda (gen) (gen)) generators)) - (runner (test-runner-current))) - (test-result-set! runner 'property-test-arguments args) - (test-result-set! runner 'property-test-iteration (+ n 1)) - (test-result-set! runner 'property-test-iterations runs) - args)))) - (iota runs))) + (unless (and (integer? runs) + (not (negative? runs))) + (error "runs must be a non-negative integer" runs)) + (do ((n 0 (+ n 1))) + ((= n runs)) + (test-error + type + (apply property + (let ((args (map (lambda (gen) (gen)) generators)) + (runner (test-runner-current))) + (test-result-set! runner 'property-test-arguments args) + (test-result-set! runner 'property-test-iteration (+ n 1)) + (test-result-set! runner 'property-test-iterations runs) + args))))) (define test-property-error (case-lambda ((property generators) |
