Test macro with logic
This commit is contained in:
@@ -222,6 +222,7 @@ class Helpers {
|
||||
interp.variables.set("k", k.forCaseParsing());
|
||||
interp.variables.set("Helpers", Helpers);
|
||||
interp.variables.set("Prelude", Prelude);
|
||||
interp.variables.set("Lambda", Lambda);
|
||||
interp.variables.set("Std", Std);
|
||||
|
||||
interps.push(interp);
|
||||
|
@@ -253,6 +253,10 @@ class BasicTestCase extends Test {
|
||||
function testDefmacro() {
|
||||
_testDefmacro();
|
||||
}
|
||||
|
||||
function testDefmacroWithLogic() {
|
||||
_testDefmacroWithLogic();
|
||||
}
|
||||
}
|
||||
|
||||
class BasicObject {
|
||||
|
@@ -379,4 +379,17 @@
|
||||
|
||||
(defun _testDefmacro []
|
||||
(Assert.equals 5 (func5))
|
||||
(Assert.equals "hello" (funcHello)))
|
||||
(Assert.equals "hello" (funcHello)))
|
||||
|
||||
(defvar &mut welcomeCount 0)
|
||||
(defmacro macroWithLogic [name]
|
||||
(deflocal message1 (ReaderExp.StrExp "Welcome "))
|
||||
(deflocal message2 (ReaderExp.StrExp " (Guest #"))
|
||||
(deflocal message3 (ReaderExp.StrExp ")"))
|
||||
|
||||
`(begin (set welcomeCount (+ welcomeCount 1))
|
||||
(+ ,message1 ,name ,message2 (Std.string welcomeCount) ,message3)))
|
||||
|
||||
(defun _testDefmacroWithLogic []
|
||||
(Assert.equals "Welcome Stevo (Guest #1)" (macroWithLogic "Stevo"))
|
||||
(Assert.equals "Welcome Bob (Guest #2)" (macroWithLogic "Bob")))
|
Reference in New Issue
Block a user