1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/ecma_5/Array/length-01.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,71 @@ 1.4 +/* 1.5 + * Any copyright is dedicated to the Public Domain. 1.6 + * http://creativecommons.org/licenses/publicdomain/ 1.7 + * Contributor: 1.8 + * Jeff Walden <jwalden+code@mit.edu> 1.9 + */ 1.10 + 1.11 +//----------------------------------------------------------------------------- 1.12 +var BUGNUMBER = 600392; 1.13 +var summary = 1.14 + 'Object.preventExtensions([]).length = 0 should do nothing, not throw'; 1.15 + 1.16 +print(BUGNUMBER + ": " + summary); 1.17 + 1.18 +/************** 1.19 + * BEGIN TEST * 1.20 + **************/ 1.21 + 1.22 + 1.23 +function testEmpty() 1.24 +{ 1.25 + var a = []; 1.26 + assertEq(a.length, 0); 1.27 + assertEq(Object.preventExtensions(a), a); 1.28 + assertEq(a.length, 0); 1.29 + a.length = 0; 1.30 + assertEq(a.length, 0); 1.31 +} 1.32 +testEmpty(); 1.33 + 1.34 +function testEmptyStrict() 1.35 +{ 1.36 + "use strict"; 1.37 + var a = []; 1.38 + assertEq(a.length, 0); 1.39 + assertEq(Object.preventExtensions(a), a); 1.40 + assertEq(a.length, 0); 1.41 + a.length = 0; 1.42 + assertEq(a.length, 0); 1.43 +} 1.44 +testEmptyStrict(); 1.45 + 1.46 +function testNonEmpty() 1.47 +{ 1.48 + var a = [1, 2, 3]; 1.49 + assertEq(a.length, 3); 1.50 + assertEq(Object.preventExtensions(a), a); 1.51 + assertEq(a.length, 3); 1.52 + a.length = 0; 1.53 + assertEq(a.length, 0); 1.54 +} 1.55 +testNonEmpty(); 1.56 + 1.57 +function testNonEmptyStrict() 1.58 +{ 1.59 + "use strict"; 1.60 + var a = [1, 2, 3]; 1.61 + assertEq(a.length, 3); 1.62 + assertEq(Object.preventExtensions(a), a); 1.63 + assertEq(a.length, 3); 1.64 + a.length = 0; 1.65 + assertEq(a.length, 0); 1.66 +} 1.67 +testNonEmptyStrict(); 1.68 + 1.69 +/******************************************************************************/ 1.70 + 1.71 +if (typeof reportCompare === "function") 1.72 + reportCompare(true, true); 1.73 + 1.74 +print("All tests passed!");