summaryrefslogtreecommitdiff
path: root/scheme/chez/geiser/test.ss
diff options
context:
space:
mode:
authorAaron Marks <nymacro@gmail.com>2020-01-03 23:29:15 +1000
committerAaron Marks <nymacro@gmail.com>2020-01-03 23:29:15 +1000
commita0f6fc32a81267154ed71f8668a1ecd227e7b37b (patch)
tree021bbf8b2136a4587177f3e91eff39f012d92d86 /scheme/chez/geiser/test.ss
parent7bc8f62409b66bdb35b934c632d7fea12a53d636 (diff)
downloadgeiser-chez-a0f6fc32a81267154ed71f8668a1ecd227e7b37b.tar.gz
geiser-chez-a0f6fc32a81267154ed71f8668a1ecd227e7b37b.tar.bz2
Add rudimentary Chez support for macro expansion0.11.20.11.10.11
Diffstat (limited to 'scheme/chez/geiser/test.ss')
-rw-r--r--scheme/chez/geiser/test.ss33
1 files changed, 32 insertions, 1 deletions
diff --git a/scheme/chez/geiser/test.ss b/scheme/chez/geiser/test.ss
index ac5503b..21f3396 100644
--- a/scheme/chez/geiser/test.ss
+++ b/scheme/chez/geiser/test.ss
@@ -1,13 +1,21 @@
(import (geiser)
(chezscheme))
+(define-syntax assert-equal
+ (syntax-rules ()
+ ((_ a b)
+ (if (equal? a b)
+ #t
+ (begin
+ (display (format "failed assertion `~a' == `~a'" a b))
+ (assert (equal? a b)))))))
(define-syntax get-result
(syntax-rules ()
((_ form)
(with-output-to-string
(lambda ()
- (geiser:eval #f form))))))
+ (geiser:eval #f form))))))
(define-syntax do-test
(syntax-rules ()
@@ -17,6 +25,29 @@
(get-result form)
result)))))
+(define-syntax do-test-macroexpand
+ (syntax-rules ()
+ ((_ form result)
+ (assert
+ (equal? (geiser:macroexpand form)
+ result)))))
+
+(define-syntax test-or
+ (syntax-rules ()
+ ((_ x) x)
+ ((_ x xs ...)
+ (if x
+ x
+ (test-or xs ...)))))
+
+(do-test-macroexpand
+ '(test-or 1)
+ '1)
+
+(do-test-macroexpand
+ '(test-or 1 2)
+ '(if 1 1 2))
+
;; (something-doesnot-exist)
;;=> Error: Exception: variable something-doesnot-exist is not bound
(do-test