Fixing PR14168

original commit: 6d06e8c66d4d3f7af5fc824e3bc4cdb7f056709d
This commit is contained in:
Jay McCarthy 2013-11-19 08:26:52 -07:00
parent cb73ddc016
commit 8f737bae4e
2 changed files with 17 additions and 8 deletions

View File

@ -1,5 +1,6 @@
#lang racket/base
(require (for-syntax racket/base)
racket/contract/base
"format.rkt"
"check.rkt")
@ -58,12 +59,16 @@
"Correct form is (test-begin expr ...)"
stx)]))
(define-syntax test-case
(syntax-rules ()
[(test-case name expr ...)
(parameterize
([current-test-name name])
(test-begin expr ...))]))
(define-syntax (test-case stx)
(syntax-case stx ()
[(_ name expr ...)
(quasisyntax/loc stx
(parameterize
([current-test-name
(contract string? name
'#,(syntax-source-module #'name #t)
'#,(syntax-source-module #'test-case #t))])
(test-begin expr ...)))]))
(define-syntax before
(syntax-rules ()

View File

@ -12,6 +12,8 @@
(test-suite
"test-case-tests"
(check-exn #rx"contract" (λ () (test-case 'foo)))
(test-case
"test-begin terminates when sub-expression fails"
(let ([fail? #f])
@ -52,6 +54,8 @@
(test-case
"dummy"
(define yes #t)
(check-true yes)))))))
(check-true yes)))))))))
))
(module+ test
(require rackunit/text-ui)
(run-tests test-case-tests))