[plt-scheme] Testing compilation of code
Hi all,
As some are aware there is a bug in SchemeUnit v2 caused by
a 3D value. Attempting to compile a path is causing the
errors people have observed with Planet.
I've decided to skip straight to v3, and not bother fixing
v2. However I'm having trouble testing this. Below is the
old test (obviously broken) from SchemeUnit v2. I really
don't understand what it is doing. I though it would be
sufficient to compile an assertion, and then
dynamic-require it. This should be done in a new
namespace.
So the question: what's a reasonable test to ensure code is
compilable?
Ta,
Noel
(test-case
"assertions are compilable"
(let ((destns (make-namespace))
(cns (current-namespace)))
(parameterize ((current-namespace destns))
(namespace-require `(,(#%info-lookup
'distribution-method)
"assert.ss"
,(#%info-lookup
'distribution-package-spec)))
;; First check that the right assert macro got
used: ie that
;; it didn't just compile the thing as an
application.
(let ((ecode (syntax-object->datum (expand
'(assert = 1 2)))))
(assert-false (and (pair? ecode)
(eq? (car ecode) '#%app)
(pair? (cdr ecode))
(equal? (cadr ecode) '(#%top
. assert)))))
;; Then check to make sure that the compiled code
is writable even
;; in the presence of strange syntax-source
objects.
(let ((stx-string "(assert = 1 2)"))
(write (compile (read-syntax (string->path
"file")
(open-input-string
stx-string)))
(open-output-string))
(write (compile (read-syntax (let-struct A ()
(make-A))
(open-input-string
stx-string)))
(open-output-string))))))
Email: noelwelsh <at> yahoo <dot> com noel <at> untyped <dot> com
AIM: noelhwelsh
Blogs: http://monospaced.blogspot.com/ http://www.untyped.com/untyping/
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com