catch a bug in while loops
This commit is contained in:
@@ -334,7 +334,7 @@ class SpecialForms {
|
||||
function whileForm(invert:Bool, wholeExp:ReaderExp, args:Array<ReaderExp>, k:KissState) {
|
||||
var funcName = if (invert) "until" else "while";
|
||||
var b = wholeExp.expBuilder();
|
||||
var cond = k.convert(b.callSymbol("Prelude.truthy", [args[0]]));
|
||||
var cond = k.convert(b.callSymbol("Prelude.truthy", [args.shift()]));
|
||||
if (invert) {
|
||||
cond = macro !$cond;
|
||||
cond = b.haxeExpr(cond);
|
||||
|
@@ -355,6 +355,10 @@ class BasicTestCase extends Test {
|
||||
_testIntersect();
|
||||
}
|
||||
|
||||
function testWhile() {
|
||||
_testWhile();
|
||||
}
|
||||
|
||||
function testWhileLet() {
|
||||
_testWhileLet();
|
||||
}
|
||||
|
@@ -675,6 +675,14 @@ From:[(assert false (+ \"false \" \"should \" \"have \" \"been \" \"true\"))]" m
|
||||
)
|
||||
(Assert.pass))
|
||||
|
||||
(function _testWhile []
|
||||
(let [max 8
|
||||
&mut current 0
|
||||
&mut iterations 0]
|
||||
(while (>= max (+= current 1))
|
||||
(+= iterations 1))
|
||||
(Assert.equals 8 iterations)))
|
||||
|
||||
(function _testWhileLet []
|
||||
(let [&mut idx 0
|
||||
lines ["a" "b" "c"]
|
||||
|
Reference in New Issue
Block a user