]>
git.saurik.com Git - apple/javascriptcore.git/blob - tests/mozilla/ecma_3/Array/regress-101488.js
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: Try assigning arr.length = new Number(n)
23 * From correspondence with Igor Bukanov <igor@icesoft.no>
24 * See http://bugzilla.mozilla.org/show_bug.cgi?id=101488
26 * Without the "new" keyword, assigning arr.length = Number(n) worked.
27 * But with it, Rhino was giving an error "Inappropriate array length"
28 * and SpiderMonkey was exiting without giving any error or return value -
30 * Comments on the Rhino code by igor@icesoft.no:
32 * jsSet_length requires that the new length value should be an instance
33 * of Number. But according to Ecma 15.4.5.1, item 12-13, an error should
34 * be thrown only if ToUint32(length_value) != ToNumber(length_value)
36 //-----------------------------------------------------------------------------
39 var summary
= 'Try assigning arr.length = new Number(n)';
43 var actualvalues
= [];
45 var expectedvalues
= [];
49 status
= inSection(1);
51 tryThis('arr.length = new Number(1);');
56 status
= inSection(2);
58 tryThis('arr.length = new Number(1);');
63 status
= inSection(3);
65 tryThis('arr.length = new Number(17);');
70 status
= inSection(4);
72 tryThis('arr.length = new Number(17);');
79 * Also try the above with the "new" keyword before Array().
80 * Array() and new Array() should be equivalent, by ECMA 15.4.1.1
82 status
= inSection(5);
84 tryThis('arr.length = new Number(1);');
89 status
= inSection(6);
91 tryThis('arr.length = new Number(1);');
97 tryThis('arr.length = new Number(17);');
102 status
= inSection(7);
104 tryThis('arr.length = new Number(17);');
111 //-----------------------------------------------------------------------------
113 //-----------------------------------------------------------------------------
132 statusitems
[UBound
] = status
;
133 actualvalues
[UBound
] = actual
;
134 expectedvalues
[UBound
] = expect
;
142 printBugNumber (bug
);
143 printStatus (summary
);
145 for (var i
=0; i
<UBound
; i
++)
147 reportCompare(expectedvalues
[i
], actualvalues
[i
], statusitems
[i
]);