js/src/tests/ecma_2/Statements/dowhile-003.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

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-003
     9  *  ECMA Section:
    10  *  Description:        do...while statements
    11  *
    12  *  Test do while, when the while expression is a JavaScript Number object.
    13  *
    14  *
    15  *  Author:             christine@netscape.com
    16  *  Date:               11 August 1998
    17  */
    18 var SECTION = "dowhile-003";
    19 var VERSION = "ECMA_2";
    20 var TITLE   = "do...while with a labeled continue statement";
    22 startTest();
    23 writeHeaderToLog( SECTION + " "+ TITLE);
    25 DoWhile( new DoWhileObject( 1, 1, 0 ));
    26 DoWhile( new DoWhileObject( 1000, 1000, 0 ));
    27 DoWhile( new DoWhileObject( 1001, 1001, 0 ));
    28 DoWhile( new DoWhileObject( 1002, 1001, 1 ));
    29 DoWhile( new DoWhileObject( -1, 1001, -1002 ));
    31 test();
    33 function DoWhileObject( value, iterations, endvalue ) {
    34   this.value = value;
    35   this.iterations = iterations;
    36   this.endvalue = endvalue;
    37 }
    39 function DoWhile( object ) {
    40   var i = 0;
    42   do {
    43     object.value =  --object.value;
    44     i++;
    45     if ( i > 1000 )
    46       break;
    47   } while( object.value );
    49   new TestCase(
    50     SECTION,
    51     "loop iterations",
    52     object.iterations,
    53     i
    54     );
    56   new TestCase(
    57     SECTION,
    58     "object.value",
    59     object.endvalue,
    60     Number( object.value )
    61     );
    63 }

mercurial