]>
git.saurik.com Git - apple/javascriptcore.git/blob - tests/mozilla/ecma/Array/15.4.5.1-2.js
1 /* The contents of this file are subject to the Netscape Public
2 * License Version 1.1 (the "License"); you may not use this file
3 * except in compliance with the License. You may obtain a copy of
4 * the License at http://www.mozilla.org/NPL/
6 * Software distributed under the License is distributed on an "AS
7 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
8 * implied. See the License for the specific language governing
9 * rights and limitations under the License.
11 * The Original Code is Mozilla Communicator client code, released March
14 * The Initial Developer of the Original Code is Netscape Communications
15 * Corporation. Portions created by Netscape are
16 * Copyright (C) 1998 Netscape Communications Corporation. All
23 File Name: 15.4.5.1-2.js
24 ECMA Section: [[ Put]] (P, V)
26 Array objects use a variation of the [[Put]] method used for other native
27 ECMAScript objects (section 8.6.2.2).
29 Assume A is an Array object and P is a string.
31 When the [[Put]] method of A is called with property P and value V, the
32 following steps are taken:
34 1. Call the [[CanPut]] method of A with name P.
35 2. If Result(1) is false, return.
36 3. If A doesn't have a property with name P, go to step 7.
37 4. If P is "length", go to step 12.
38 5. Set the value of property P of A to V.
40 7. Create a property with name P, set its value to V and give it empty
42 8. If P is not an array index, return.
43 9. If A itself has a property (not an inherited property) named "length",
44 andToUint32(P) is less than the value of the length property of A, then
46 10. Change (or set) the value of the length property of A to ToUint32(P)+1.
48 12. Compute ToUint32(V).
49 13. For every integer k that is less than the value of the length property
50 of A but not less than Result(12), if A itself has a property (not an
51 inherited property) named ToString(k), then delete that property.
52 14. Set the value of property P of A to Result(12).
56 These are testcases from Waldemar, detailed in
57 http://scopus.mcom.com/bugsplat/show_bug.cgi?id=123552
59 Author: christine@netscape.com
63 var SECTION
= "15.4.5.1-2";
64 var VERSION
= "ECMA_1";
66 var TITLE
= "Array [[Put]] (P,V)";
68 writeHeaderToLog( SECTION
+ " "+ TITLE
);
70 var testcases
= new Array();
74 AddCase( "3.00", "three" );
75 AddCase( "00010", "eight" );
76 AddCase( "37xyz", "thirty-five" );
77 AddCase("5000000000", 5)
80 testcases
[tc
++] = new TestCase( SECTION
,
85 testcases
[tc
++] = new TestCase( SECTION
,
92 testcases
[tc
++] = new TestCase( SECTION
,
93 "a[4] = \"four\"; a[4]",
97 testcases
[tc
++] = new TestCase( SECTION
,
102 testcases
[tc
++] = new TestCase( SECTION
,
107 testcases
[tc
++] = new TestCase( SECTION
,
115 testcases
[tc
++] = new TestCase( SECTION
,
116 "a[\"5000000000\"] = 5; a.length",
120 testcases
[tc
++] = new TestCase( SECTION
,
121 "a[\"-2\"] = -3; a.length",
127 function AddCase ( arg
, value
) {
131 testcases
[tc
++] = new TestCase( SECTION
,
132 "a[\"" + arg
+ "\"] = "+ value
+"; a.length",
139 for ( tc
=0; tc
< testcases
.length
; tc
++ ) {
140 testcases
[tc
].passed
= writeTestCaseResult(
141 testcases
[tc
].expect
,
142 testcases
[tc
].actual
,
143 testcases
[tc
].description
+" = "+
144 testcases
[tc
].actual
);
146 testcases
[tc
].reason
+= ( testcases
[tc
].passed
) ? "" : "wrong value ";
149 return ( testcases
);