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.
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 /**
8 * File Name: dowhile-006
9 * ECMA Section:
10 * Description: do...while statements
11 *
12 * A general do...while test.
13 *
14 * Author: christine@netscape.com
15 * Date: 26 August 1998
16 */
17 var SECTION = "dowhile-006";
18 var VERSION = "ECMA_2";
19 var TITLE = "do...while";
21 startTest();
22 writeHeaderToLog( SECTION + " "+ TITLE);
24 DoWhile( new DoWhileObject( false, false, 10 ) );
25 DoWhile( new DoWhileObject( true, false, 2 ) );
26 DoWhile( new DoWhileObject( false, true, 3 ) );
27 DoWhile( new DoWhileObject( true, true, 4 ) );
29 test();
31 function looping( object ) {
32 object.iterations--;
34 if ( object.iterations <= 0 ) {
35 return false;
36 } else {
37 return true;
38 }
39 }
40 function DoWhileObject( breakOut, breakIn, iterations, loops ) {
41 this.iterations = iterations;
42 this.loops = loops;
43 this.breakOut = breakOut;
44 this.breakIn = breakIn;
45 this.looping = looping;
46 }
47 function DoWhile( object ) {
48 var result1 = false;
49 var result2 = false;
51 outie: {
52 innie: {
53 do {
54 if ( object.breakOut )
55 break outie;
57 if ( object.breakIn )
58 break innie;
60 } while ( looping(object) );
62 // statements should be executed if:
63 // do...while exits normally
64 // do...while exits abruptly with no label
66 result1 = true;
68 }
70 // statements should be executed if:
71 // do...while breaks out with label "innie"
72 // do...while exits normally
73 // do...while does not break out with "outie"
75 result2 = true;
76 }
78 new TestCase(
79 SECTION,
80 "hit code after loop in inner loop",
81 ( object.breakIn || object.breakOut ) ? false : true ,
82 result1 );
84 new TestCase(
85 SECTION,
86 "hit code after loop in outer loop",
87 ( object.breakOut ) ? false : true,
88 result2 );
89 }