aboutsummaryrefslogtreecommitdiffstats
path: root/csc/macros-test.csc
diff options
context:
space:
mode:
Diffstat (limited to 'csc/macros-test.csc')
-rw-r--r--csc/macros-test.csc152
1 files changed, 152 insertions, 0 deletions
diff --git a/csc/macros-test.csc b/csc/macros-test.csc
index 007b881..4cc8efa 100644
--- a/csc/macros-test.csc
+++ b/csc/macros-test.csc
@@ -10,3 +10,155 @@
(assert-equal
(make-constant '(test 1 2 3))
(expand '(quote (test 1 2 3)) test-environment)))
+
+
+(test builtin-syntax-rules-literal
+ (assert-equal
+ (make-constant 1)
+ (expand
+ '(builtin-let-syntax
+ (foo
+ (syntax-rules (a b)
+ ((foo a)
+ 0)
+ ((foo b)
+ 1)))
+ (foo b))
+ test-environment)))
+
+
+(test builtin-syntax-rules-underscore
+ (assert-equal
+ (make-constant 0)
+ (expand
+ '(builtin-let-syntax
+ (foo
+ (syntax-rules ()
+ ((foo _) 0)))
+ (foo ignored))
+ test-environment)))
+
+
+(test builtin-syntax-rules-substitution
+ (assert-equal
+ (make-constant 5)
+ (expand
+ '(builtin-let-syntax
+ (foo
+ (syntax-rules ()
+ ((foo x) x)))
+ (foo 5))
+ test-environment)))
+
+
+(test builtin-syntax-rules-nil
+ (assert-equal
+ (make-constant 1)
+ (expand
+ '(builtin-let-syntax
+ (foo
+ (syntax-rules ()
+ ((foo x) 0)
+ ((foo) 1)))
+ (foo))
+ test-environment)))
+
+
+(test builtin-syntax-rules-improper-list
+ (assert-equal
+ (make-constant 1)
+ (expand
+ '(builtin-let-syntax
+ (foo
+ (syntax-rules ()
+ ((foo a . b) a)))
+ (foo 1 2 3))
+ test-environment)))
+
+
+(test builtin-syntax-rules-quoted
+ (assert-equal
+ (make-constant 'a)
+ (expand
+ '(builtin-let-syntax
+ (foo
+ (syntax-rules ()
+ ((foo x) (quote x))))
+ (foo a))
+ test-environment)))
+
+
+(test builtin-syntax-rules-constant
+ (assert-equal
+ (make-constant 2)
+ (expand
+ '(builtin-let-syntax
+ (foo
+ (syntax-rules ()
+ ((foo "abc") 0)
+ ((foo "def") 1)
+ ((foo "ghi") 2)))
+ (foo "ghi"))
+ test-environment)))
+
+
+(test builtin-syntax-rules-ellipsis
+ (assert-equal
+ (make-constant 5)
+ (expand
+ '(builtin-let-syntax
+ (foo
+ (syntax-rules ()
+ ((foo x ...) (x ...))))
+ (foo quote 5))
+ test-environment)))
+
+
+(test builtin-syntax-rules-ellipsis-improper
+ (assert-equal
+ (make-constant 5)
+ (expand
+ '(builtin-let-syntax
+ (foo
+ (syntax-rules ()
+ ((foo x ... . y) (x ... y))))
+ (foo quote . 5))
+ test-environment)))
+
+
+(test builtin-syntax-rules-ellipsis-zip
+ (assert-equal
+ (make-constant '((1 . 3) (2 . 4)))
+ (expand
+ '(builtin-let-syntax
+ (zip
+ (syntax-rules ()
+ ((zip (x ...) (y ...))
+ (quote ((x . y) ...)))))
+ (zip (1 2) (3 4)))
+ test-environment)))
+
+
+(test builtin-syntax-rules-ellipsis-nested
+ (assert-equal
+ (make-constant '(1 2 3 4 5))
+ (expand
+ '(builtin-let-syntax
+ (append
+ (syntax-rules ()
+ ((append (x ...) ...)
+ (quote (x ... ...)))))
+ (append (1 2) (3 4) () (5)))
+ test-environment)))
+
+
+(test builtin-syntax-rules-ellipsis-custom
+ (assert-equal
+ (make-constant 5)
+ (expand
+ '(builtin-let-syntax
+ (foo
+ (syntax-rules ::: ()
+ ((foo x :::) (x :::))))
+ (foo quote 5))
+ test-environment)))