1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/ecma_2/Statements/dowhile-004.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,67 @@ 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-004 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 + * Author: christine@netscape.com 1.19 + * Date: 11 August 1998 1.20 + */ 1.21 +var SECTION = "dowhile-004"; 1.22 +var VERSION = "ECMA_2"; 1.23 +var TITLE = "do...while with a labeled continue statement"; 1.24 + 1.25 +startTest(); 1.26 +writeHeaderToLog( SECTION + " "+ TITLE); 1.27 + 1.28 +DoWhile( 0, 1 ); 1.29 +DoWhile( 1, 1 ); 1.30 +DoWhile( -1, 1 ); 1.31 +DoWhile( 5, 5 ); 1.32 + 1.33 +test(); 1.34 + 1.35 +function DoWhile( limit, expect ) { 1.36 + i = 0; 1.37 + result1 = "pass"; 1.38 + result2 = "failed: broke out of labeled statement unexpectedly"; 1.39 + 1.40 +foo: { 1.41 + do { 1.42 + i++; 1.43 + if ( ! (i < limit) ) { 1.44 + break; 1.45 + result1 = "fail: evaluated statement after a labeled break"; 1.46 + } 1.47 + } while ( true ); 1.48 + 1.49 + result2 = "pass"; 1.50 + } 1.51 + 1.52 + new TestCase( 1.53 + SECTION, 1.54 + "do while ( " + i +" < " + limit +" )", 1.55 + expect, 1.56 + i ); 1.57 + 1.58 + new TestCase( 1.59 + SECTION, 1.60 + "breaking out of a do... while loop", 1.61 + "pass", 1.62 + result1 ); 1.63 + 1.64 + 1.65 + new TestCase( 1.66 + SECTION, 1.67 + "breaking out of a labeled do...while loop", 1.68 + "pass", 1.69 + result2 ); 1.70 +}