• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/**
2 *  File Name:          dowhile-003
3 *  ECMA Section:
4 *  Description:        do...while statements
5 *
6 *  Test do while, when the while expression is a JavaScript Number object.
7 *
8 *
9 *  Author:             christine@netscape.com
10 *  Date:               11 August 1998
11 */
12    var SECTION = "dowhile-003";
13    var VERSION = "ECMA_2";
14    var TITLE   = "do...while with a labeled continue statement";
15
16    startTest();
17    writeHeaderToLog( SECTION + " "+ TITLE);
18
19    var tc = 0;
20    var testcases = new Array();
21
22    DoWhile( new DoWhileObject( 1, 1, 0 ));
23    DoWhile( new DoWhileObject( 1000, 1000, 0 ));
24    DoWhile( new DoWhileObject( 1001, 1001, 0 ));
25    DoWhile( new DoWhileObject( 1002, 1001, 1 ));
26    DoWhile( new DoWhileObject( -1, 1001, -1002 ));
27
28    test();
29
30function DoWhileObject( value, iterations, endvalue ) {
31    this.value = value;
32    this.iterations = iterations;
33    this.endvalue = endvalue;
34}
35
36function DoWhile( object ) {
37    var i = 0;
38
39    do {
40        object.value =  --object.value;
41        i++;
42        if ( i > 1000 )
43            break;
44   } while( object.value );
45
46   testcases[tc++] = new TestCase(
47        SECTION,
48        "loop iterations",
49        object.iterations,
50        i
51    );
52
53   testcases[tc++] = new TestCase(
54        SECTION,
55        "object.value",
56        object.endvalue,
57        Number( object.value )
58    );
59
60}