| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
gTestfile = 'dowhile-004.js'; |
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
var SECTION = "dowhile-004"; |
| 20 |
var VERSION = "ECMA_2"; |
| 21 |
var TITLE = "do...while with a labeled continue statement"; |
| 22 |
|
| 23 |
startTest(); |
| 24 |
writeHeaderToLog( SECTION + " "+ TITLE); |
| 25 |
|
| 26 |
DoWhile( 0, 1 ); |
| 27 |
DoWhile( 1, 1 ); |
| 28 |
DoWhile( -1, 1 ); |
| 29 |
DoWhile( 5, 5 ); |
| 30 |
|
| 31 |
test(); |
| 32 |
|
| 33 |
function DoWhile( limit, expect ) { |
| 34 |
i = 0; |
| 35 |
result1 = "pass"; |
| 36 |
result2 = "failed: broke out of labeled statement unexpectedly"; |
| 37 |
|
| 38 |
foo: { |
| 39 |
do { |
| 40 |
i++; |
| 41 |
if ( ! (i < limit) ) { |
| 42 |
break; |
| 43 |
result1 = "fail: evaluated statement after a labeled break"; |
| 44 |
} |
| 45 |
} while ( true ); |
| 46 |
|
| 47 |
result2 = "pass"; |
| 48 |
} |
| 49 |
|
| 50 |
new TestCase( |
| 51 |
SECTION, |
| 52 |
"do while ( " + i +" < " + limit +" )", |
| 53 |
expect, |
| 54 |
i ); |
| 55 |
|
| 56 |
new TestCase( |
| 57 |
SECTION, |
| 58 |
"breaking out of a do... while loop", |
| 59 |
"pass", |
| 60 |
result1 ); |
| 61 |
|
| 62 |
|
| 63 |
new TestCase( |
| 64 |
SECTION, |
| 65 |
"breaking out of a labeled do...while loop", |
| 66 |
"pass", |
| 67 |
result2 ); |
| 68 |
} |