js/src/tests/ecma_5/Array/length-01.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:b8eaae1859b3
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 */
7
8 //-----------------------------------------------------------------------------
9 var BUGNUMBER = 600392;
10 var summary =
11 'Object.preventExtensions([]).length = 0 should do nothing, not throw';
12
13 print(BUGNUMBER + ": " + summary);
14
15 /**************
16 * BEGIN TEST *
17 **************/
18
19
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();
30
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();
42
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();
53
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();
65
66 /******************************************************************************/
67
68 if (typeof reportCompare === "function")
69 reportCompare(true, true);
70
71 print("All tests passed!");

mercurial