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())
class MacroExpandTestCase extends Test {
function testObjectFormWithAlias() {
_testObjectFormWithAlias();
}
function testLambdaFormWithAlias() {
_testLambdaFormWithAlias();
function testAllForms() {
_testAllForms();
Assert.pass();
}
}

View File

@@ -1,31 +1,20 @@
(defAlias &ident Stream kiss.Stream)
(defMacroFunction example []
`(object
Stream (Stream.fromString "")))
(defMacro makeExample [expression &body b]
`(let [normal ,(printExp expression)
expanded ,(printExp (macroExpand expression))]
,@b))
(defMacro normalExample []
(printExp (example)))
(function _testAllForms []
(makeExample
(object
Stream (Stream.fromString ""))
normal.Stream
expanded.Stream)
(defMacro macroExpandExample []
(printExp (macroExpand (example))))
(function _testObjectFormWithAlias []
.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))
(makeExample
(lambda [Stream] (Stream.fromString ""))
(normal null)
(expanded null))
)