[plt-scheme] Testing whole module
Sorry, I did not mention a run time flag. I said: expansion time switch :)
Something like
(module to-be-tested-or-not-to-be-tested mzscheme
(define-for-syntax checking? #f) ; set to #t for if checking is desired
; dont forget to switch it back (and may be recompile) when you are satisfied.
(define-syntax (only-when-checking stx)
(syntax-case stx ()
((_ expr ...)
(if checking? #'(begin expr ...) #'#t))))
; I guess that during optimization the module-top-level exprs expanding to
(#%datum . #t) are removed.
; and if not, well they do no harm.
...
(only-when-checking
test1
test 2
,,,)))
Of course it is possible to use a run time flag-parameter and wrapping test
code in (if (flag-parameter) (begin ...))
but I guess that is not what you want. I would not want it either, because I
dont want to contaminate
a released module with unnecessary code in it.
Greetings, Jos
----- Original Message -----
From: "Paulo J. Matos" <pocm at soton.ac.uk>
To: "Jos Koot" <jos.koot at telefonica.net>
Cc: "PLT-Scheme Mailing List" <plt-scheme at list.cs.brown.edu>
Sent: Monday, August 06, 2007 9:37 PM
Subject: Re: [plt-scheme] Testing whole module
> On 06/08/07, Jos Koot <jos.koot at telefonica.net> wrote:
>> Another nasty method is
>> (parameterize ((current-namespace (module->namespace module-spec))) test
>> ...),
>> but you can't do this within a module. It requires top level (argh)
>> A neater method is to include the checks in the module itself with an
>> expansion
>> time switch that turns checking on/off in the expansion phase.
>
> Do you have any tip on how to do the neat method? I can't seem to
> figure out how to ignore a piece of code of a module in run time using
> a run-time flag.
>
>> Jos Koot
>>
>> ----- Original Message -----
>> From: "Paulo J. Matos" <pocm at soton.ac.uk>
>> To: "PLT-Scheme Mailing List" <plt-scheme at list.cs.brown.edu>
>> Sent: Monday, August 06, 2007 6:56 PM
>> Subject: [plt-scheme] Testing whole module
>>
>>
>> > Hi all,
>> >
>> > I'm using SchemeUnit for unit testing and I just created a test module
>> > foo-test.scm for foo.scm but I just realized I'll only be able to
>> > access/test functions provided by foo.scm. I would like to test also
>> > functions _not_ provided by foo but which should be tested. What's the
>> > best approach for this?
>> >
>> > Cheers,
>> > --
>> > Paulo Jorge Matos - pocm at soton.ac.uk
>> > http://www.personal.soton.ac.uk/pocm
>> > PhD Student @ ECS
>> > University of Southampton, UK
>> > _________________________________________________
>> > For list-related administrative tasks:
>> > http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>> >
>>
>>
>>
>>
>
>
> --
> Paulo Jorge Matos - pocm at soton.ac.uk
> http://www.personal.soton.ac.uk/pocm
> PhD Student @ ECS
> University of Southampton, UK
>