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.
Robby On Sun, Apr 7, 2013 at 1:47 AM, Eric Dobson <eric.n.dob...@gmail.com> wrote: > The issue with that is that it runs the code (compute) at phase1, when > I need to run that code at phase 0, otherwise compiling the module > runs the tests. I'm willing to muck with eval and namespaces, so I > believe what I want should be possible if difficult. > > > On Sat, Apr 6, 2013 at 11:34 PM, Ryan Culpepper <ry...@ccs.neu.edu> wrote: > > On 04/07/2013 01:24 AM, Eric Dobson wrote: > >> > >> I am trying to test a helper to a macro. It generates a syntax object > >> with bindings at phase-1, this is then returned by the macro and it > >> correctly evaluates. Is there a way to not go through the macro, but > >> still evaluate the syntax-object with those bindings it has at phase-1 > >> relative to the helper and not phase 0 relative? > >> > >> Example code: > >> #lang racket/load > >> > >> (module t racket > >> (provide (all-defined-out)) > >> (define temp 7)) > >> > >> (module stx-compute racket > >> (provide (all-defined-out)) > >> (require (for-template 't)) > >> ;(require 't) > >> (define (compute) #'temp)) > >> > >> > >> (module stx racket > >> (provide (all-defined-out)) > >> (require (for-syntax 'stx-compute)) > >> (define-syntax (use-compute stx) > >> (compute))) > >> > >> (require 'stx) > >> (displayln (use-compute)) > >> (require 'stx-compute) > >> (displayln (eval-syntax (compute))) > >> > >> This fails on the eval-syntax, but succeds if I uncomment the (require > >> 't). > > > > > > You might find phase1-eval from unstable/macro-testing helpful. > > > > (require (for-syntax 'stx-compute) > > unstable/macro-testing)) > > > > (phase1-eval (compute)) > > ;; => 'temp > > > > (phase1-eval (compute) #:quote quote-syntax) > > ;; => #<syntax temp> > > > > (eval-syntax (phase1-eval (compute) #:quote quote-syntax)) > > ;; => 7 > > > > Ryan > > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users >
____________________ Racket Users list: http://lists.racket-lang.org/users