throwCompileError in expBuilder

This commit is contained in:
2021-11-10 15:45:04 -07:00
parent 2eb24a8c3f
commit db3402f885
7 changed files with 80 additions and 6 deletions

View File

@@ -46,6 +46,10 @@ class MacroTestCase extends Test {
_testSetMacroVar();
}
function testRedefineMacroVar() {
_testRedefineMacroVar();
}
function testTryCatchWithoutDynamic () {
_testTryCatchWithoutDynamic();
}

View File

@@ -60,6 +60,7 @@
(_testPrintAtMacroTimeMacro)
(Assert.pass))
// Calling (set) on a macroVar is a faux-pas, but calling defMacroVar again is not
(defMacroVar count 0)
(defMacro _testSetMacroVarMacro []
(assertThrows (set count (+ count 1)))
@@ -69,6 +70,15 @@
(_testSetMacroVarMacro)
(Assert.pass))
(defMacro _testRedefineMacroVarMacro []
(defMacroVar count (+ count 1))
(symbol (Std.string count)))
(function _testRedefineMacroVar []
(Assert.equals 1 (_testRedefineMacroVarMacro))
(Assert.equals 2 (_testRedefineMacroVarMacro)))
// ifLet and its derivatives should be disabled in defMacro bodies:
(defMacro _testIfLetDisabledMacro []
(assertThrows (ifLet [a "b"] a))