Debian Codegraph @

rhino/testsrc/tests/ecma_2/Statements/dowhile-006.js

raw symbols SCIP
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/. */
5
6 gTestfile = 'dowhile-006.js';
7
8 /**
9 * File Name: dowhile-006
10 * ECMA Section:
11 * Description: do...while statements
12 *
13 * A general do...while test.
14 *
15 * Author: [email protected]
16 * Date: 26 August 1998
17 */
18 var SECTION = "dowhile-006";
19 var VERSION = "ECMA_2";
20 var TITLE = "do...while";
21
22 startTest();
23 writeHeaderToLog( SECTION + " "+ TITLE);
24
25 DoWhile( new DoWhileObject( false, false, 10 ) );
26 DoWhile( new DoWhileObject( true, false, 2 ) );
27 DoWhile( new DoWhileObject( false, true, 3 ) );
28 DoWhile( new DoWhileObject( true, true, 4 ) );
29
30 test();
31
32 function looping( object ) {
33 object.iterations--;
34
35 if ( object.iterations <= 0 ) {
36 return false;
37 } else {
38 return true;
39 }
40 }
41 function DoWhileObject( breakOut, breakIn, iterations, loops ) {
42 this.iterations = iterations;
43 this.loops = loops;
44 this.breakOut = breakOut;
45 this.breakIn = breakIn;
46 this.looping = looping;
47 }
48 function DoWhile( object ) {
49 var result1 = false;
50 var result2 = false;
51
52 outie: {
53 innie: {
54 do {
55 if ( object.breakOut )
56 break outie;
57
58 if ( object.breakIn )
59 break innie;
60
61 } while ( looping(object) );
62
63 // statements should be executed if:
64 // do...while exits normally
65 // do...while exits abruptly with no label
66
67 result1 = true;
68
69 }
70
71 // statements should be executed if:
72 // do...while breaks out with label "innie"
73 // do...while exits normally
74 // do...while does not break out with "outie"
75
76 result2 = true;
77 }
78
79 new TestCase(
80 SECTION,
81 "hit code after loop in inner loop",
82 ( object.breakIn || object.breakOut ) ? false : true ,
83 result1 );
84
85 new TestCase(
86 SECTION,
87 "hit code after loop in outer loop",
88 ( object.breakOut ) ? false : true,
89 result2 );
90 }