1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/ecma_2/Statements/dowhile-005.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,73 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 + 1.10 +/** 1.11 + * File Name: dowhile-005 1.12 + * ECMA Section: 1.13 + * Description: do...while statements 1.14 + * 1.15 + * Test a labeled do...while. Break out of the loop with no label 1.16 + * should break out of the loop, but not out of the label. 1.17 + * 1.18 + * Currently causes an infinite loop in the monkey. Uncomment the 1.19 + * print statement below and it works OK. 1.20 + * 1.21 + * Author: christine@netscape.com 1.22 + * Date: 26 August 1998 1.23 + */ 1.24 +var SECTION = "dowhile-005"; 1.25 +var VERSION = "ECMA_2"; 1.26 +var TITLE = "do...while with a labeled continue statement"; 1.27 +var BUGNUMBER = "316293"; 1.28 + 1.29 +startTest(); 1.30 +writeHeaderToLog( SECTION + " "+ TITLE); 1.31 + 1.32 +NestedLabel(); 1.33 + 1.34 + 1.35 +test(); 1.36 + 1.37 +function NestedLabel() { 1.38 + i = 0; 1.39 + result1 = "pass"; 1.40 + result2 = "fail: did not hit code after inner loop"; 1.41 + result3 = "pass"; 1.42 + 1.43 +outer: { 1.44 + do { 1.45 + inner: { 1.46 +// print( i ); 1.47 + break inner; 1.48 + result1 = "fail: did break out of inner label"; 1.49 + } 1.50 + result2 = "pass"; 1.51 + break outer; 1.52 + print(i); 1.53 + } while ( i++ < 100 ); 1.54 + 1.55 + } 1.56 + 1.57 + result3 = "fail: did not break out of outer label"; 1.58 + 1.59 + new TestCase( 1.60 + SECTION, 1.61 + "number of loop iterations", 1.62 + 0, 1.63 + i ); 1.64 + 1.65 + new TestCase( 1.66 + SECTION, 1.67 + "break out of inner loop", 1.68 + "pass", 1.69 + result1 ); 1.70 + 1.71 + new TestCase( 1.72 + SECTION, 1.73 + "break out of outer loop", 1.74 + "pass", 1.75 + result2 ); 1.76 +}