assert return the value of the asserted expression

This commit is contained in:
2021-10-28 14:54:00 -04:00
parent a29f2934d9
commit d96c4f30fa
3 changed files with 20 additions and 4 deletions

View File

@@ -314,9 +314,17 @@ class Macros {
} else {
b.str(basicMessage);
};
b.callSymbol("unless", [
expression,
b.callSymbol("throw", [messageExp])
var letVal = b.symbol();
b.callSymbol("let", [
b.list([
letVal,
expression
]),
b.callSymbol("if", [
letVal,
letVal,
b.callSymbol("throw", [messageExp])
])
]);
};

View File

@@ -44,8 +44,13 @@ class MacroTestCase extends Test {
function testSetMacroVar() {
_testSetMacroVar();
}
*/
function testTryCatchWithoutDynamic () {
_testTryCatchWithoutDynamic();
}
function testAssertReturnsValue () {
_testAssertReturnsValue();
}
}

View File

@@ -95,4 +95,7 @@
(try (throw "intended") (catch [e] (ReaderExp.StrExp e))))
(function _testTryCatchWithoutDynamic []
(Assert.equals "intended" (_testTryCatchWithoutDynamicMacro)))
(Assert.equals "intended" (_testTryCatchWithoutDynamicMacro)))
(function _testAssertReturnsValue []
(Assert.equals true (assert true)))