1/** 2 * File Name: dowhile-004 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 * Author: christine@netscape.com 10 * Date: 11 August 1998 11 */ 12 var SECTION = "dowhile-004"; 13 var VERSION = "ECMA_2"; 14 var TITLE = "do...while with a labeled continue statement"; 15 16 startTest(); 17 writeHeaderToLog( SECTION + " "+ TITLE); 18 19 var tc = 0; 20 var testcases = new Array(); 21 22 DoWhile( 0, 1 ); 23 DoWhile( 1, 1 ); 24 DoWhile( -1, 1 ); 25 DoWhile( 5, 5 ); 26 27 test(); 28 29function DoWhile( limit, expect ) { 30 i = 0; 31 result1 = "pass"; 32 result2 = "failed: broke out of labeled statement unexpectedly"; 33 34 foo: { 35 do { 36 i++; 37 if ( ! (i < limit) ) { 38 break; 39 result1 = "fail: evaluated statement after a labeled break"; 40 } 41 } while ( true ); 42 43 result2 = "pass"; 44 } 45 46 testcases[tc++] = new TestCase( 47 SECTION, 48 "do while ( " + i +" < " + limit +" )", 49 expect, 50 i ); 51 52 testcases[tc++] = new TestCase( 53 SECTION, 54 "breaking out of a do... while loop", 55 "pass", 56 result1 ); 57 58 59 testcases[tc++] = new TestCase( 60 SECTION, 61 "breaking out of a labeled do...while loop", 62 "pass", 63 result2 ); 64} 65