Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | |
michael@0 | 7 | /** |
michael@0 | 8 | * File Name: dowhile-004 |
michael@0 | 9 | * ECMA Section: |
michael@0 | 10 | * Description: do...while statements |
michael@0 | 11 | * |
michael@0 | 12 | * Test a labeled do...while. Break out of the loop with no label |
michael@0 | 13 | * should break out of the loop, but not out of the label. |
michael@0 | 14 | * |
michael@0 | 15 | * Author: christine@netscape.com |
michael@0 | 16 | * Date: 11 August 1998 |
michael@0 | 17 | */ |
michael@0 | 18 | var SECTION = "dowhile-004"; |
michael@0 | 19 | var VERSION = "ECMA_2"; |
michael@0 | 20 | var TITLE = "do...while with a labeled continue statement"; |
michael@0 | 21 | |
michael@0 | 22 | startTest(); |
michael@0 | 23 | writeHeaderToLog( SECTION + " "+ TITLE); |
michael@0 | 24 | |
michael@0 | 25 | DoWhile( 0, 1 ); |
michael@0 | 26 | DoWhile( 1, 1 ); |
michael@0 | 27 | DoWhile( -1, 1 ); |
michael@0 | 28 | DoWhile( 5, 5 ); |
michael@0 | 29 | |
michael@0 | 30 | test(); |
michael@0 | 31 | |
michael@0 | 32 | function DoWhile( limit, expect ) { |
michael@0 | 33 | i = 0; |
michael@0 | 34 | result1 = "pass"; |
michael@0 | 35 | result2 = "failed: broke out of labeled statement unexpectedly"; |
michael@0 | 36 | |
michael@0 | 37 | foo: { |
michael@0 | 38 | do { |
michael@0 | 39 | i++; |
michael@0 | 40 | if ( ! (i < limit) ) { |
michael@0 | 41 | break; |
michael@0 | 42 | result1 = "fail: evaluated statement after a labeled break"; |
michael@0 | 43 | } |
michael@0 | 44 | } while ( true ); |
michael@0 | 45 | |
michael@0 | 46 | result2 = "pass"; |
michael@0 | 47 | } |
michael@0 | 48 | |
michael@0 | 49 | new TestCase( |
michael@0 | 50 | SECTION, |
michael@0 | 51 | "do while ( " + i +" < " + limit +" )", |
michael@0 | 52 | expect, |
michael@0 | 53 | i ); |
michael@0 | 54 | |
michael@0 | 55 | new TestCase( |
michael@0 | 56 | SECTION, |
michael@0 | 57 | "breaking out of a do... while loop", |
michael@0 | 58 | "pass", |
michael@0 | 59 | result1 ); |
michael@0 | 60 | |
michael@0 | 61 | |
michael@0 | 62 | new TestCase( |
michael@0 | 63 | SECTION, |
michael@0 | 64 | "breaking out of a labeled do...while loop", |
michael@0 | 65 | "pass", |
michael@0 | 66 | result2 ); |
michael@0 | 67 | } |