js/src/tests/ecma_5/Array/pop-nonarray-higher-elements.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  */
     6 //-----------------------------------------------------------------------------
     7 var BUGNUMBER = 909602;
     8 var summary =
     9   "Array.prototype.pop shouldn't touch elements greater than length on " +
    10   "non-arrays";
    12 print(BUGNUMBER + ": " + summary);
    14 /**************
    15  * BEGIN TEST *
    16  **************/
    18 function doTest(obj, index)
    19 {
    20   // print("testing " + JSON.stringify(obj) + " with index " + index);
    21   assertEq(Array.prototype.pop.call(obj), undefined);
    22   assertEq(index in obj, true);
    23   assertEq(obj[index], 42);
    24 }
    26 // not-super-much-later element
    28 // non-zero length
    29 function testPop1()
    30 {
    31   var obj = { length: 2, 3: 42 };
    32   doTest(obj, 3);
    33 }
    34 for (var i = 0; i < 50; i++)
    35   testPop1();
    37 // zero length
    38 function testPop2()
    39 {
    40   var obj = { length: 0, 3: 42 };
    41   doTest(obj, 3);
    42 }
    43 for (var i = 0; i < 50; i++)
    44   testPop2();
    46 // much-later (but dense) element
    48 // non-zero length
    49 function testPop3()
    50 {
    51   var obj = { length: 2, 55: 42 };
    52   doTest(obj, 55);
    53 }
    54 for (var i = 0; i < 50; i++)
    55   testPop3();
    57 // zero length
    58 function testPop4()
    59 {
    60   var obj = { length: 0, 55: 42 };
    61   doTest(obj, 55);
    62 }
    63 for (var i = 0; i < 50; i++)
    64   testPop4();
    66 // much much much later (sparse) element
    68 // non-zero length
    69 function testPop5()
    70 {
    71   var obj = { length: 2, 65530: 42 };
    72   doTest(obj, 65530);
    73 }
    74 for (var i = 0; i < 50; i++)
    75   testPop5();
    77 // zero length
    78 function testPop6()
    79 {
    80   var obj = { length: 0, 65530: 42 };
    81   doTest(obj, 65530);
    82 }
    83 for (var i = 0; i < 50; i++)
    84   testPop6();
    86 /******************************************************************************/
    88 if (typeof reportCompare === "function")
    89   reportCompare(true, true);
    91 print("Tests complete");

mercurial