1
0
mirror of https://github.com/robertkrimen/otto synced 2025-10-26 20:28:49 +08:00

Fix iterator evaluation to return the proper result if a break happens

This commit is contained in:
Robert Krimen
2013-04-27 19:26:48 +02:00
parent cc243b17d7
commit cfd5635e46
7 changed files with 134 additions and 88 deletions

View File

@@ -265,15 +265,20 @@ func TestDoWhile(t *testing.T) {
test := runTest()
test(`
limit = 4
result = 0
limit = 4;
result = 0;
do {
result = result + 1
limit = limit - 1
}
while (limit)
`)
test("result", "4")
result = result + 1;
limit = limit - 1;
} while (limit);
result;
`, "4")
test(`
console.log("Xyzzy");
result = eval("do {abc=1; break; abc=2;} while (0);");
[ result, abc ];
`, "1,1")
}
func TestWhile(t *testing.T) {