1 /** 2 * File Name: dowhile-005 3 * ECMA Section: 4 * Description: do...while statements 5 * 6 * Test a labeled do...while. Break out of the loop with no label 7 * should break out of the loop, but not out of the label. 8 * 9 * Currently causes an infinite loop in the monkey. Uncomment the 10 * print statement below and it works OK. 11 * 12 * Author: christine (at) netscape.com 13 * Date: 26 August 1998 14 */ 15 var SECTION = "dowhile-005"; 16 var VERSION = "ECMA_2"; 17 var TITLE = "do...while with a labeled continue statement"; 18 var BUGNUMBER = "316293"; 19 20 startTest(); 21 writeHeaderToLog( SECTION + " "+ TITLE); 22 23 var tc = 0; 24 var testcases = new Array(); 25 26 NestedLabel(); 27 28 29 test(); 30 31 function NestedLabel() { 32 i = 0; 33 result1 = "pass"; 34 result2 = "fail: did not hit code after inner loop"; 35 result3 = "pass"; 36 37 outer: { 38 do { 39 inner: { 40 // print( i ); 41 break inner; 42 result1 = "fail: did break out of inner label"; 43 } 44 result2 = "pass"; 45 break outer; 46 print (i); 47 } while ( i++ < 100 ); 48 49 } 50 51 result3 = "fail: did not break out of outer label"; 52 53 testcases[tc++] = new TestCase( 54 SECTION, 55 "number of loop iterations", 56 0, 57 i ); 58 59 testcases[tc++] = new TestCase( 60 SECTION, 61 "break out of inner loop", 62 "pass", 63 result1 ); 64 65 testcases[tc++] = new TestCase( 66 SECTION, 67 "break out of outer loop", 68 "pass", 69 result2 ); 70 }