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.

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

mercurial