js/src/tests/ecma_5/Array/length-01.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 /*
     2  * Any copyright is dedicated to the Public Domain.
     3  * http://creativecommons.org/licenses/publicdomain/
     4  * Contributor:
     5  *   Jeff Walden <jwalden+code@mit.edu>
     6  */
     8 //-----------------------------------------------------------------------------
     9 var BUGNUMBER = 600392;
    10 var summary =
    11   'Object.preventExtensions([]).length = 0 should do nothing, not throw';
    13 print(BUGNUMBER + ": " + summary);
    15 /**************
    16  * BEGIN TEST *
    17  **************/
    20 function testEmpty()
    21 {
    22   var a = [];
    23   assertEq(a.length, 0);
    24   assertEq(Object.preventExtensions(a), a);
    25   assertEq(a.length, 0);
    26   a.length = 0;
    27   assertEq(a.length, 0);
    28 }
    29 testEmpty();
    31 function testEmptyStrict()
    32 {
    33   "use strict";
    34   var a = [];
    35   assertEq(a.length, 0);
    36   assertEq(Object.preventExtensions(a), a);
    37   assertEq(a.length, 0);
    38   a.length = 0;
    39   assertEq(a.length, 0);
    40 }
    41 testEmptyStrict();
    43 function testNonEmpty()
    44 {
    45   var a = [1, 2, 3];
    46   assertEq(a.length, 3);
    47   assertEq(Object.preventExtensions(a), a);
    48   assertEq(a.length, 3);
    49   a.length = 0;
    50   assertEq(a.length, 0);
    51 }
    52 testNonEmpty();
    54 function testNonEmptyStrict()
    55 {
    56   "use strict";
    57   var a = [1, 2, 3];
    58   assertEq(a.length, 3);
    59   assertEq(Object.preventExtensions(a), a);
    60   assertEq(a.length, 3);
    61   a.length = 0;
    62   assertEq(a.length, 0);
    63 }
    64 testNonEmptyStrict();
    66 /******************************************************************************/
    68 if (typeof reportCompare === "function")
    69   reportCompare(true, true);
    71 print("All tests passed!");

mercurial