2 * The contents of this file are subject to the Netscape Public
3 * License Version 1.1 (the "License"); you may not use this file
4 * except in compliance with the License. You may obtain a copy of
5 * the License at http://www.mozilla.org/NPL/
7 * Software distributed under the License is distributed on an "AS
8 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
9 * implied. See the License for the specific language governing
10 * rights and limitations under the License.
12 * The Original Code is mozilla.org code.
14 * The Initial Developer of the Original Code is Netscape
15 * Communications Corporation. Portions created by Netscape are
16 * Copyright (C) 1998 Netscape Communications Corporation.
17 * All Rights Reserved.
19 * Contributor(s): igor@icesoft.no, pschwartau@netscape.com
20 * Date: 24 September 2001
22 * SUMMARY: Truncating arrays that have decimal property names.
23 * From correspondence with Igor Bukanov <igor@icesoft.no>:
25 //-----------------------------------------------------------------------------
28 var summary = 'Truncating arrays that have decimal property names';
29 var BIG_INDEX = 4294967290;
33 var actualvalues = [];
35 var expectedvalues = [];
38 var arr = Array(BIG_INDEX);
39 arr[BIG_INDEX - 1] = 'a';
40 arr[BIG_INDEX - 10000] = 'b';
41 arr[BIG_INDEX - 0.5] = 'c'; // not an array index - but a valid property name
42 // Truncate the array -
43 arr.length = BIG_INDEX - 5000;
46 // Enumerate its properties with for..in
55 * We expect s == 'cb' or 'bc' (EcmaScript does not fix the order).
56 * Note 'c' is included: for..in includes ALL enumerable properties,
57 * not just array-index properties. The bug was: Rhino gave s == ''.
59 status = inSection(1);
66 //-----------------------------------------------------------------------------
68 //-----------------------------------------------------------------------------
72 function sortThis(str)
74 var chars = str.split('');
76 return chars.join('');
82 statusitems[UBound] = status;
83 actualvalues[UBound] = actual;
84 expectedvalues[UBound] = expect;
93 printStatus (summary);
95 for (var i=0; i<UBound; i++)
97 reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);