michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: michael@0: /** michael@0: File Name: 15.4.5.1-2.js michael@0: ECMA Section: [[ Put]] (P, V) michael@0: Description: michael@0: Array objects use a variation of the [[Put]] method used for other native michael@0: ECMAScript objects (section 8.6.2.2). michael@0: michael@0: Assume A is an Array object and P is a string. michael@0: michael@0: When the [[Put]] method of A is called with property P and value V, the michael@0: following steps are taken: michael@0: michael@0: 1. Call the [[CanPut]] method of A with name P. michael@0: 2. If Result(1) is false, return. michael@0: 3. If A doesn't have a property with name P, go to step 7. michael@0: 4. If P is "length", go to step 12. michael@0: 5. Set the value of property P of A to V. michael@0: 6. Go to step 8. michael@0: 7. Create a property with name P, set its value to V and give it empty michael@0: attributes. michael@0: 8. If P is not an array index, return. michael@0: 9. If A itself has a property (not an inherited property) named "length", michael@0: andToUint32(P) is less than the value of the length property of A, then michael@0: return. michael@0: 10. Change (or set) the value of the length property of A to ToUint32(P)+1. michael@0: 11. Return. michael@0: 12. Compute ToUint32(V). michael@0: 13. For every integer k that is less than the value of the length property michael@0: of A but not less than Result(12), if A itself has a property (not an michael@0: inherited property) named ToString(k), then delete that property. michael@0: 14. Set the value of property P of A to Result(12). michael@0: 15. Return. michael@0: michael@0: michael@0: These are gTestcases from Waldemar, detailed in michael@0: http://scopus.mcom.com/bugsplat/show_bug.cgi?id=123552 michael@0: michael@0: Author: christine@netscape.com michael@0: Date: 15 June 1998 michael@0: */ michael@0: michael@0: var SECTION = "15.4.5.1-2"; michael@0: var VERSION = "ECMA_1"; michael@0: startTest(); michael@0: var TITLE = "Array [[Put]] (P,V)"; michael@0: michael@0: writeHeaderToLog( SECTION + " "+ TITLE); michael@0: michael@0: var a = new Array(); michael@0: michael@0: AddCase( "3.00", "three" ); michael@0: AddCase( "00010", "eight" ); michael@0: AddCase( "37xyz", "thirty-five" ); michael@0: AddCase("5000000000", 5) michael@0: AddCase( "-2", -3 ); michael@0: michael@0: new TestCase( SECTION, michael@0: "a[10]", michael@0: void 0, michael@0: a[10] ); michael@0: michael@0: new TestCase( SECTION, michael@0: "a[3]", michael@0: void 0, michael@0: a[3] ); michael@0: michael@0: a[4] = "four"; michael@0: michael@0: new TestCase( SECTION, michael@0: "a[4] = \"four\"; a[4]", michael@0: "four", michael@0: a[4] ); michael@0: michael@0: new TestCase( SECTION, michael@0: "a[\"4\"]", michael@0: "four", michael@0: a["4"] ); michael@0: michael@0: new TestCase( SECTION, michael@0: "a[\"4.00\"]", michael@0: void 0, michael@0: a["4.00"] ); michael@0: michael@0: new TestCase( SECTION, michael@0: "a.length", michael@0: 5, michael@0: a.length ); michael@0: michael@0: michael@0: a["5000000000"] = 5; michael@0: michael@0: new TestCase( SECTION, michael@0: "a[\"5000000000\"] = 5; a.length", michael@0: 5, michael@0: a.length ); michael@0: michael@0: new TestCase( SECTION, michael@0: "a[\"-2\"] = -3; a.length", michael@0: 5, michael@0: a.length ); michael@0: michael@0: test(); michael@0: michael@0: function AddCase ( arg, value ) { michael@0: michael@0: a[arg] = value; michael@0: michael@0: new TestCase( SECTION, michael@0: "a[\"" + arg + "\"] = "+ value +"; a.length", michael@0: 0, michael@0: a.length ); michael@0: }