<div dir="ltr">You can put your helper code in a submodule that you require from the test module at phase 0 but from the actual module at phase 1.<br><br>Robby<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Sun, Apr 7, 2013 at 1:47 AM, Eric Dobson <span dir="ltr"><<a href="mailto:eric.n.dobson@gmail.com" target="_blank">eric.n.dobson@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
The issue with that is that it runs the code (compute) at phase1, when<br>
I need to run that code at phase 0, otherwise compiling the module<br>
runs the tests. I'm willing to muck with eval and namespaces, so I<br>
believe what I want should be possible if difficult.<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
On Sat, Apr 6, 2013 at 11:34 PM, Ryan Culpepper <<a href="mailto:ryanc@ccs.neu.edu">ryanc@ccs.neu.edu</a>> wrote:<br>
> On 04/07/2013 01:24 AM, Eric Dobson wrote:<br>
>><br>
>> I am trying to test a helper to a macro. It generates a syntax object<br>
>> with bindings at phase-1, this is then returned by the macro and it<br>
>> correctly evaluates. Is there a way to not go through the macro, but<br>
>> still evaluate the syntax-object with those bindings it has at phase-1<br>
>> relative to the helper and not phase 0 relative?<br>
>><br>
>> Example code:<br>
>> #lang racket/load<br>
>><br>
>> (module t racket<br>
>> (provide (all-defined-out))<br>
>> (define temp 7))<br>
>><br>
>> (module stx-compute racket<br>
>> (provide (all-defined-out))<br>
>> (require (for-template 't))<br>
>> ;(require 't)<br>
>> (define (compute) #'temp))<br>
>><br>
>><br>
>> (module stx racket<br>
>> (provide (all-defined-out))<br>
>> (require (for-syntax 'stx-compute))<br>
>> (define-syntax (use-compute stx)<br>
>> (compute)))<br>
>><br>
>> (require 'stx)<br>
>> (displayln (use-compute))<br>
>> (require 'stx-compute)<br>
>> (displayln (eval-syntax (compute)))<br>
>><br>
>> This fails on the eval-syntax, but succeds if I uncomment the (require<br>
>> 't).<br>
><br>
><br>
> You might find phase1-eval from unstable/macro-testing helpful.<br>
><br>
> (require (for-syntax 'stx-compute)<br>
> unstable/macro-testing))<br>
><br>
> (phase1-eval (compute))<br>
> ;; => 'temp<br>
><br>
> (phase1-eval (compute) #:quote quote-syntax)<br>
> ;; => #<syntax temp><br>
><br>
> (eval-syntax (phase1-eval (compute) #:quote quote-syntax))<br>
> ;; => 7<br>
><br>
> Ryan<br>
><br>
____________________<br>
Racket Users list:<br>
<a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
</div></div></blockquote></div><br></div>