mirror of https://github.com/svaarala/duktape.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
943 B
67 lines
943 B
11 years ago
|
/*===
|
||
|
0
|
||
|
1
|
||
|
2
|
||
|
3
|
||
|
4
|
||
|
5
|
||
|
while done
|
||
|
===*/
|
||
|
|
||
|
function test1() {
|
||
|
var i;
|
||
|
labelled:
|
||
|
do {
|
||
|
for (i = 0; i < 100; i++) {
|
||
|
print(i);
|
||
|
if (i == 5) { break labelled; }
|
||
|
}
|
||
|
throw new Error('never here');
|
||
|
} while(true);
|
||
|
print('while done');
|
||
|
}
|
||
|
|
||
|
function test2() {
|
||
|
var i = 0;
|
||
|
labelled:
|
||
|
do {
|
||
|
print(i);
|
||
|
if (i++ == 5) { break labelled; }
|
||
|
} while(true);
|
||
|
print('while done');
|
||
|
}
|
||
|
|
||
|
/* Here the special thing is that the labelled statement is a block,
|
||
|
* not an iterator statement directly.
|
||
|
*/
|
||
|
function test3() {
|
||
|
var i = 0;
|
||
|
labelled:
|
||
|
{
|
||
|
do {
|
||
|
print(i);
|
||
|
if (i++ == 5) { break labelled; }
|
||
|
} while(true);
|
||
|
throw new Error('never here');
|
||
|
}
|
||
|
print('while done');
|
||
|
}
|
||
|
|
||
|
try {
|
||
|
test1();
|
||
|
} catch (e) {
|
||
|
print(e);
|
||
|
}
|
||
|
|
||
|
try {
|
||
|
test2();
|
||
|
} catch (e) {
|
||
|
print(e);
|
||
|
}
|
||
|
|
||
|
try {
|
||
|
test3();
|
||
|
} catch (e) {
|
||
|
print(e);
|
||
|
}
|