test + fix for an ifLet regression
This commit is contained in:
@@ -699,21 +699,24 @@ class Macros {
|
||||
var gensym = b.symbol();
|
||||
return b.let(
|
||||
[gensym, firstValue],
|
||||
[b.callSymbol("case", [
|
||||
[b.callSymbol("if", [
|
||||
gensym,
|
||||
b.call(
|
||||
b.callSymbol("when", [gensym, firstPattern]), [
|
||||
if (bindingList.length == 0) {
|
||||
thenExp;
|
||||
} else {
|
||||
ifLet(assertLet, wholeExp, [
|
||||
b.list(bindingList)
|
||||
].concat(exps.slice(1)), k);
|
||||
}
|
||||
]),
|
||||
b.callSymbol("otherwise", [
|
||||
elseExp
|
||||
])
|
||||
b.callSymbol("case", [
|
||||
gensym,
|
||||
b.call(firstPattern, [
|
||||
if (bindingList.length == 0) {
|
||||
thenExp;
|
||||
} else {
|
||||
ifLet(assertLet, wholeExp, [
|
||||
b.list(bindingList)
|
||||
].concat(exps.slice(1)), k);
|
||||
}
|
||||
]),
|
||||
b.callSymbol("otherwise", [
|
||||
elseExp
|
||||
])
|
||||
]),
|
||||
elseExp
|
||||
])]);
|
||||
}
|
||||
macros["ifLet"] = ifLet.bind(false);
|
||||
|
@@ -364,6 +364,9 @@ class BasicTestCase extends Test {
|
||||
_testQuickFractions();
|
||||
}
|
||||
|
||||
function testWhenLetGuards() {
|
||||
_testWhenLetGuards();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@@ -689,3 +689,8 @@ From:[(assert false (+ \"false \" \"should \" \"have \" \"been \" \"true\"))]" m
|
||||
(function _testQuickFractions []
|
||||
(Assert.equals 0.5 (fHalf 1))
|
||||
(Assert.equals 0 (iHalf 1)))
|
||||
|
||||
(function _testWhenLetGuards []
|
||||
// Guards should be allowed in whenLet patterns
|
||||
(whenLet [(when true 5) 5]
|
||||
(Assert.pass)))
|
Reference in New Issue
Block a user