[plt-scheme] Exposing non-exported module variable bindings.
Raymond Racine wrote:
> Here's a little trick to write SchemeUnit tests in a separate file which
> allows testing a modules exported and unexported variable bindings. The
> module/expose macro exposes simple non-provided variable bindings for
> testing.
...
> (define-syntax module/expose
> (syntax-rules ()
> ((_ mod (id1 ...))
> (begin
> (require mod)
> (define-values (id1 ...)
> (let ([ns (module->namespace mod)])
> (parameterize ([current-namespace ns])
> (values
> (namespace-variable-value 'id1 #t void) ...))))))))
>
> (module/expose "mod.scm" (a b)) ;; expose non-provided a and b bindings.
This reminds me of something Eli posted to c.l.s:
(define-syntax in-module
(syntax-rules ()
((in-module m expr ...)
(parameterize ((current-namespace (module->namespace 'm)))
(eval '(begin expr ...))))))
In which case your test could be written:
(require mod)
(in-module mod
(test/text-ui
(make-test-suite ... a ... b ...)))
-d