Refactor MacroExpandTestCase

This commit is contained in:
2024-02-17 10:09:05 -07:00
parent 5668bf0195
commit 92d9f42388
2 changed files with 18 additions and 32 deletions

View File

@@ -14,12 +14,9 @@ using StringTools;
@:build(kiss.Kiss.build()) @:build(kiss.Kiss.build())
class MacroExpandTestCase extends Test { class MacroExpandTestCase extends Test {
function testObjectFormWithAlias() { function testAllForms() {
_testObjectFormWithAlias(); _testAllForms();
} Assert.pass();
function testLambdaFormWithAlias() {
_testLambdaFormWithAlias();
} }
} }

View File

@@ -1,31 +1,20 @@
(defAlias &ident Stream kiss.Stream) (defAlias &ident Stream kiss.Stream)
(defMacroFunction example [] (defMacro makeExample [expression &body b]
`(object `(let [normal ,(printExp expression)
Stream (Stream.fromString ""))) expanded ,(printExp (macroExpand expression))]
,@b))
(defMacro normalExample [] (function _testAllForms []
(printExp (example))) (makeExample
(object
Stream (Stream.fromString ""))
normal.Stream
expanded.Stream)
(defMacro macroExpandExample [] (makeExample
(printExp (macroExpand (example)))) (lambda [Stream] (Stream.fromString ""))
(normal null)
(function _testObjectFormWithAlias [] (expanded null))
.Stream (normalExample)
.Stream (macroExpandExample)
(Assert.pass))
(defMacroFunction example2 []
`(lambda [Stream] (Stream.fromString "")))
(defMacro normalExample2 []
(printExp (example2)))
(defMacro macroExpandExample2 []
(printExp (macroExpand (example2))))
(function _testLambdaFormWithAlias []
(localVar l (normalExample2))
(localVar l2 (macroExpandExample2))
(Assert.pass))
)