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.
41 lines
1.5 KiB
Racket
41 lines
1.5 KiB
Racket
10 years ago
|
#lang racket/base
|
||
10 years ago
|
(require (for-syntax racket/base racket/syntax))
|
||
9 years ago
|
(require "define.rkt")
|
||
10 years ago
|
(provide+safe module-test-external module-test-internal module-test-internal+external)
|
||
10 years ago
|
|
||
|
;; tests using module-boundary contracts
|
||
|
(define-syntax (module-test-external stx)
|
||
|
(syntax-case stx ()
|
||
|
[(_ expr ...)
|
||
9 years ago
|
(let ([mod-name (syntax-e (generate-temporary))])
|
||
|
(datum->syntax stx
|
||
|
`(begin
|
||
|
(module* ,mod-name racket/base
|
||
|
(require (submod ".."))
|
||
|
(require rackunit)
|
||
|
,@(syntax->datum #'(expr ...)))
|
||
|
(module+ test
|
||
|
(require (submod ".." ,mod-name))))
|
||
|
stx))]))
|
||
10 years ago
|
|
||
|
(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)
|
||
9 years ago
|
(module-test-external ,@exprs)) stx))]))
|