fix undefinition of print before other MacroTestCases

This commit is contained in:
2021-11-09 15:39:43 -07:00
parent f218b75ac4
commit 93ad7cd3b5
3 changed files with 27 additions and 3 deletions

View File

@@ -85,7 +85,7 @@ class KissInterp extends Interp {
}
override function exprReturn(e):Dynamic {
// the default exprReturn() contains a try-catch which, though it is important, hides very important macroexpansion callstacks sometimes
// the default exprReturn() contains a try-catch which, though it is important (break, continue, and return statements require it), hides very important macroexpansion callstacks sometimes
#if macrotest
return expr(e);
#else

View File

@@ -25,7 +25,8 @@ class MacroTestCase extends Test {
}
function testUndefAlias() {
Assert.equals(9, print);
Assert.equals(9, chooseRandom);
Assert.equals(6, print(5));
Assert.equals(9, aliasValue());
}

View File

@@ -98,4 +98,27 @@
(Assert.equals "intended" (_testTryCatchWithoutDynamicMacro)))
(function _testAssertReturnsValue []
(Assert.equals true (assert true)))
(Assert.equals true (assert true)))
// DANGEROUS tests:
// (don't add new tests below here, because these tests redefine important forms)
// If for whatever reason, you wanted to make a variable with the name of a built-in identifier alias:
(undefAlias &ident chooseRandom)
(var chooseRandom 9)
// Also if you want a function called print:
(undefAlias &call print)
(function print [thing] (+ 1 thing))
(defAlias &ident alias 5)
(undefAlias &ident alias)
(var alias 9)
(function aliasValue [] alias)
// If for whatever reason, you wanted to make a function called and
(undefMacro and)
(function and [a b] (+ a b))
(function andValue [] (and 5 6))