[racket] Submodule access in nested function definitions

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Wed Mar 18 09:10:34 EDT 2015

You really do need to do something special to lift out the tests in
that kind of situation. You could track the variables bound by the
outer use of define/tc and communicate them to the inner one and then
lift out a function that accepted the outer define/tc's arguments and
put that function into the test submodule. Then the test cases for the
outer function would run test cases for the inner ones but when the
code is actually running you wouldn't run its test cases all the time.

Robby


On Wed, Mar 18, 2015 at 7:54 AM, Rickard Andersson
<rickard.m.andersson at abv.bg> wrote:
> Hi, everyone.
>
> So, the background for this e-mail is the following macro:
>
> http://pasterack.org/pastes/51673
>
> In short, it allows me to do function definition closely connected with
> contracts as well as test cases.
>
> The problem I ran into last time I worked on this, though, is that I
> can't actually use the `define/tc/module` version in nested function.
> I'd like to use that version because it adds a "(module+ test
> <testcases> ...)" which I consider neater.
>
> I'm looking at this again because I was trying to use Greg
> Hendershott's amazing racket-mode for emacs and when you try to autorun
> the tests with it you run your test submodule. Tests work fine with
> `raco test` but I still want to use the test submodule because it's
> neater.
>
> In terms of execution, will not using the submodule hinder anything
> else, except not being as easily integrated in, for example,
> racket-mode? As per the macro definition, the set of `check-equal?`
> calls are just appended after the function definition.
>
> Any advice on how to get around this is appreciated, as is any
> information about what 'stray' check-equal?s may mean in terms of risks
> to performance, errors and so on.
>
> (Sidenote: Nesting `define/tc` works, but will also run more test cases
> than specified.)
>
> // Rickard Andersson [gonz_]
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users

Posted on the users mailing list.