• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/**
2 *  File Name:          dowhile-007
3 *  ECMA Section:
4 *  Description:        do...while statements
5 *
6 *  A general do...while test.
7 *
8 *  Author:             christine@netscape.com
9 *  Date:               26 August 1998
10 */
11    var SECTION = "dowhile-007";
12    var VERSION = "ECMA_2";
13    var TITLE   = "do...while";
14
15    startTest();
16    writeHeaderToLog( SECTION + " "+ TITLE);
17
18    var tc = 0;
19    var testcases = new Array();
20
21    DoWhile( new DoWhileObject( false, false, false, false ));
22    DoWhile( new DoWhileObject( true, false, false, false ));
23    DoWhile( new DoWhileObject( true, true, false, false ));
24    DoWhile( new DoWhileObject( true, true, true, false ));
25    DoWhile( new DoWhileObject( true, true, true, true ));
26    DoWhile( new DoWhileObject( false, false, false, true ));
27    DoWhile( new DoWhileObject( false, false, true, true ));
28    DoWhile( new DoWhileObject( false, true, true, true ));
29    DoWhile( new DoWhileObject( false, false, true, false ));
30
31    test();
32
33function DoWhileObject( out1, out2, out3, in1 ) {
34    this.breakOutOne = out1;
35    this.breakOutTwo = out2;
36    this.breakOutThree = out3;
37    this.breakIn = in1;
38}
39function DoWhile( object ) {
40    result1 = false;
41    result2 = false;
42    result3 = false;
43    result4 = false;
44
45    outie:
46        do {
47            if ( object.breakOutOne ) {
48                break outie;
49            }
50            result1 = true;
51
52            innie:
53                do {
54                    if ( object.breakOutTwo ) {
55                        break outie;
56                    }
57                    result2 = true;
58
59                    if ( object.breakIn ) {
60                        break innie;
61                    }
62                    result3 = true;
63
64                } while ( false );
65                    if ( object.breakOutThree ) {
66                        break outie;
67                    }
68                    result4 = true;
69        } while ( false );
70
71        testcases[tc++] = new TestCase(
72            SECTION,
73            "break one: ",
74            (object.breakOutOne) ? false : true,
75            result1 );
76
77        testcases[tc++] = new TestCase(
78            SECTION,
79            "break two: ",
80            (object.breakOutOne||object.breakOutTwo) ? false : true,
81            result2 );
82
83        testcases[tc++] = new TestCase(
84            SECTION,
85            "break three: ",
86            (object.breakOutOne||object.breakOutTwo||object.breakIn) ? false : true,
87            result3 );
88
89        testcases[tc++] = new TestCase(
90            SECTION,
91            "break four: ",
92            (object.breakOutOne||object.breakOutTwo||object.breakOutThree) ? false: true,
93            result4 );
94}
95