commit 30d5a8780b39835beb8c22cab6cfb98bf9cac85c parent 2f60ad5e27dc8c46bce3ede800af81a246e16f6d Author: Stephen Chang <stchang@ccs.neu.edu> Date: Thu, 14 Jul 2016 12:50:05 -0400 add random testing check-equal Diffstat:
| M | turnstile/examples/tests/rackunit-typechecking.rkt | | | 15 | ++++++++++++++- |
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/turnstile/examples/tests/rackunit-typechecking.rkt b/turnstile/examples/tests/rackunit-typechecking.rkt @@ -1,6 +1,7 @@ #lang racket/base (require (for-syntax rackunit syntax/srcloc) rackunit macrotypes/typecheck) -(provide check-type typecheck-fail check-not-type check-props check-runtime-exn) +(provide check-type typecheck-fail check-not-type check-props check-runtime-exn + check-equal/rand) (begin-for-syntax (define (add-esc s) (string-append "\\" s)) @@ -90,3 +91,15 @@ [(_ e) #:with e- (expand/df #'e) (syntax/loc stx (check-exn exn:fail? (lambda () e-)))])) + +(define-simple-macro (check-equal/rand f (~optional (~seq #:process p) + #:defaults ([p #'(lambda (x) x)]))) + #:with f* (format-id #'f "~a*" #'f) + #:with out (syntax/loc this-syntax (check-equal/rand-fn f f* p)) + out) +(define-check (check-equal/rand-fn f f* process) + (for ([i 100000]) + (let ([ks (for/list ([n (procedure-arity f)]) (random 4294967087))]) + (with-check-info (['f f] ['inputs ks]) + (check-equal? (apply f (map process ks)) + (apply f* (map process ks)))))))