From 93ad7cd3b5bb6422a4ef1a0694855140a8f2d130 Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Tue, 9 Nov 2021 15:39:43 -0700 Subject: [PATCH] fix undefinition of print before other MacroTestCases --- src/kiss/KissInterp.hx | 2 +- src/test/cases/MacroTestCase.hx | 3 ++- src/test/cases/MacroTestCase.kiss | 25 ++++++++++++++++++++++++- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/kiss/KissInterp.hx b/src/kiss/KissInterp.hx index 36a6a7f..50b1418 100644 --- a/src/kiss/KissInterp.hx +++ b/src/kiss/KissInterp.hx @@ -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 diff --git a/src/test/cases/MacroTestCase.hx b/src/test/cases/MacroTestCase.hx index 717cff9..d35aea6 100644 --- a/src/test/cases/MacroTestCase.hx +++ b/src/test/cases/MacroTestCase.hx @@ -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()); } diff --git a/src/test/cases/MacroTestCase.kiss b/src/test/cases/MacroTestCase.kiss index 98f7c02..f93a218 100644 --- a/src/test/cases/MacroTestCase.kiss +++ b/src/test/cases/MacroTestCase.kiss @@ -98,4 +98,27 @@ (Assert.equals "intended" (_testTryCatchWithoutDynamicMacro))) (function _testAssertReturnsValue [] - (Assert.equals true (assert true))) \ No newline at end of file + (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))