How to Test Functions that are not Exported from a Module

Paulos asked here how to unit test module functions that are not exported. Eli explained two solutions here:

; 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.

Leave a Reply

Your email address will not be published. Required fields are marked *