adjust testing macro

pull/5/head
Matthew Butterick 9 years ago
parent b96d0d5e56
commit 8f9991070a

@ -1,27 +1,27 @@
#lang racket/base #lang racket/base
(require (for-syntax racket/base racket/syntax)) (require (for-syntax racket/base racket/syntax syntax/strip-context))
;; use a separate test file to avoid cycle in loading ;; use a separate test file to avoid cycle in loading
(define-syntax (test-safe-and-unsafe stx) (define-syntax (test-safe-and-unsafe stx)
(syntax-case stx () (syntax-case stx ()
[(_ exprs ...) [(_ exprs ...)
(with-syntax ([sym (syntax-e (generate-temporary))] (with-syntax ([module-without-contracts (generate-temporary)]
[sym2 (syntax-e (generate-temporary))]) [module-with-contracts (generate-temporary)])
(datum->syntax stx `(begin (replace-context stx #'(begin
(module ,(syntax->datum #'sym) racket (module module-without-contracts racket
(require rackunit "main.rkt") (require rackunit "main.rkt")
(define-syntax (values->list stx) (define-syntax (values->list stx)
(syntax-case stx () (syntax-case stx ()
[(_ values-expr) #'(call-with-values (λ () values-expr) list)])) [(_ values-expr) #'(call-with-values (λ () values-expr) list)]))
,@(syntax->datum #'(exprs ...))) exprs ...)
(require ',(syntax->datum #'sym)) (require 'module-without-contracts)
(module ,(syntax->datum #'sym2) racket (module module-with-contracts racket
(require rackunit (submod "main.rkt" safe)) (require rackunit (submod "main.rkt" safe))
(define-syntax (values->list stx) (define-syntax (values->list stx)
(syntax-case stx () (syntax-case stx ()
[(_ values-expr) #'(call-with-values (λ () values-expr) list)])) [(_ values-expr) #'(call-with-values (λ () values-expr) list)]))
,@(syntax->datum #'(exprs ...))) exprs ...)
(require ',(syntax->datum #'sym2))) stx))])) (require 'module-with-contracts))))]))
(test-safe-and-unsafe (test-safe-and-unsafe

Loading…
Cancel
Save