2005-08-19 Florian Gross <flgr@ccan.de>
[mono.git] / mcs / class / Microsoft.JScript / Test / Mozilla / ecma_2 / Statements / dowhile-006.js
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /**
3  *  File Name:          dowhile-006
4  *  ECMA Section:
5  *  Description:        do...while statements
6  *
7  *  A general do...while test.
8  *
9  *  Author:             christine@netscape.com
10  *  Date:               26 August 1998
11  */
12 var SECTION = "dowhile-006";
13 var VERSION = "ECMA_2";
14 var TITLE   = "do...while";
15
16 startTest();
17 writeHeaderToLog( SECTION + " "+ TITLE);
18
19 DoWhile( new DoWhileObject( false, false, 10 ) );
20 DoWhile( new DoWhileObject( true, false, 2 ) );
21 DoWhile( new DoWhileObject( false, true, 3 ) );
22 DoWhile( new DoWhileObject( true, true, 4 ) );
23
24 test();
25
26 function looping( object ) {
27   object.iterations--;
28
29   if ( object.iterations <= 0 ) {
30     return false;
31   } else {
32     return true;
33   }
34 }
35 function DoWhileObject( breakOut, breakIn, iterations, loops ) {
36   this.iterations = iterations;
37   this.loops = loops;
38   this.breakOut = breakOut;
39   this.breakIn  = breakIn;
40   this.looping  = looping;
41 }
42 function DoWhile( object ) {
43   var result1 = false;
44   var result2 = false;
45
46 outie: {
47 innie: {
48   do {
49     if ( object.breakOut )
50       break outie;
51
52     if ( object.breakIn )
53       break innie;
54
55   } while ( looping(object) );
56
57   //  statements should be executed if:
58   //  do...while exits normally
59   //  do...while exits abruptly with no label
60
61   result1 = true;
62
63 }
64
65 //  statements should be executed if:
66 //  do...while breaks out with label "innie"
67 //  do...while exits normally
68 //  do...while does not break out with "outie"
69
70 result2 = true;
71   }
72
73   new TestCase(
74     SECTION,
75     "hit code after loop in inner loop",
76     ( object.breakIn || object.breakOut ) ? false : true ,
77     result1 );
78
79   new TestCase(
80     SECTION,
81     "hit code after loop in outer loop",
82     ( object.breakOut ) ? false : true,
83     result2 );
84 }