You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.3 KiB
Racket
39 lines
1.3 KiB
Racket
#lang racket/base
|
|
(require (for-syntax racket/base racket/syntax))
|
|
(require sugar/define)
|
|
(provide+safe module-test-external module-test-internal module-test-internal+external)
|
|
|
|
;; tests using module-boundary contracts
|
|
(define-syntax (module-test-external stx)
|
|
(syntax-case stx ()
|
|
[(_ expr ...)
|
|
(with-syntax ([mod-name (generate-temporary)])
|
|
#'(begin
|
|
(module* mod-name racket/base
|
|
(require (submod ".."))
|
|
(require rackunit)
|
|
expr ...)
|
|
(module+ test
|
|
(require (submod ".." mod-name)))))]))
|
|
|
|
|
|
(define-syntax (module-test-internal stx)
|
|
(syntax-case stx ()
|
|
[(_ expr ...)
|
|
(let ([exprs (syntax->datum #'(expr ...))])
|
|
(datum->syntax stx `(begin
|
|
(module+ test
|
|
(require rackunit)
|
|
,@exprs))
|
|
;; pass original stx for srcloc
|
|
;; which is not precisely accurate but
|
|
;; OK for now
|
|
stx))]))
|
|
|
|
(define-syntax (module-test-internal+external stx)
|
|
(syntax-case stx ()
|
|
[(_ expr ...)
|
|
(let ([exprs (syntax->datum #'(expr ...))])
|
|
(datum->syntax stx `(begin
|
|
(module-test-internal ,@exprs)
|
|
(module-test-external ,@exprs)) stx))])) |