diff options
| author | Rose Hogenson <rhogenson@posteo.net> | 2022-08-12 16:59:42 -0700 |
|---|---|---|
| committer | Rose Hogenson <rhogenson@posteo.net> | 2022-08-12 16:59:42 -0700 |
| commit | d4bd262329827738d08a431f9556fbe6fa8d5a80 (patch) | |
| tree | 5c4aa1e8ff02861ed49af04edf5228ba4860c7de /lib/csc/macros-test.csc | |
| parent | Subtract int-min instead of adding int-max + 1. (diff) | |
| download | chromatopelma-d4bd262329827738d08a431f9556fbe6fa8d5a80.tar.zst | |
Fix bugs in the macro expander.
Now I'm following the rule that you should ignore marks that were added
after the binding was defined. I also introduced a lexical environment
to handle lambdas.
Diffstat (limited to 'lib/csc/macros-test.csc')
| -rw-r--r-- | lib/csc/macros-test.csc | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/csc/macros-test.csc b/lib/csc/macros-test.csc index 9b4c128..be573cb 100644 --- a/lib/csc/macros-test.csc +++ b/lib/csc/macros-test.csc @@ -37,6 +37,7 @@ make-letrec make-lexical-ref make-lexical-set + make-library-define make-library-ref make-sequence sequence?) @@ -238,6 +239,22 @@ transform-ir1)) + (test builtin-syntax-rules-define + (assert-equal + (make-library-define (make-library-ref 'exit 'main) + (make-lambda '() #f (make-sequence (make-constant #f) (make-call-builtin 'exit (list (make-library-ref 'code 'main)))))) + (expand-body 'main + '((let-syntax + (define + (syntax-rules () + ((define (f . args) body ...) + (builtin-define f (lambda args body ...))))) + (define (exit) + (call-builtin exit code)))) + builtins-environment) + transform-ir1)) + + (define (test-ref sym) (make-lexical-ref sym (gensym))) @@ -257,6 +274,16 @@ transform-ir1)) + (test builtin-lambda-ref + (assert-equal + (make-lambda (list (test-ref 'x)) #f + (make-sequence (make-constant #f) (test-ref 'x))) + (expand-body 'main + '((lambda (x) x)) + builtins-environment) + transform-ir1)) + + (test builtin-case-lambda-defines (assert-equal (make-lambda (list (test-ref 'x)) #f |
