[plt-scheme] Interaction of schemeunit with modules

From: Eli Barzilay (eli at barzilay.org)
Date: Wed May 20 01:36:40 EDT 2009

On May 20, Paulo J. Matos wrote:
> Hi all,
> 
> I am testing a couple of modules and some of them export a single
> function, however, I want to create tests that test internal
> functions individually but requiring the module in the test module
> only imports the single procedure I export so I end up being hands
> tied when it comes to testing the other functions. What's the
> reasonable approach to circumvent this issue?  It would be probably
> nice, I guess, to be able to say "hey, the tests module in X should
> see it all in X!"

One way to do this is with `module->namespace' to get the namespace of
the module (I think that this is how `require/expose' works).  Another
way which is very convenient for testing is to use the sandbox:

  (require scheme/sandbox)
  (define e (make-module-evaluator (string->path "some-file")))

and at this point you have `e' bound to an evaluator that works inside
of your module, similarly to the repl in drscheme.

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                  http://www.barzilay.org/                 Maze is Life!


Posted on the users mailing list.