Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 /**
8 File Name: 15.4.5.1-2.js
9 ECMA Section: [[ Put]] (P, V)
10 Description:
11 Array objects use a variation of the [[Put]] method used for other native
12 ECMAScript objects (section 8.6.2.2).
14 Assume A is an Array object and P is a string.
16 When the [[Put]] method of A is called with property P and value V, the
17 following steps are taken:
19 1. Call the [[CanPut]] method of A with name P.
20 2. If Result(1) is false, return.
21 3. If A doesn't have a property with name P, go to step 7.
22 4. If P is "length", go to step 12.
23 5. Set the value of property P of A to V.
24 6. Go to step 8.
25 7. Create a property with name P, set its value to V and give it empty
26 attributes.
27 8. If P is not an array index, return.
28 9. If A itself has a property (not an inherited property) named "length",
29 andToUint32(P) is less than the value of the length property of A, then
30 return.
31 10. Change (or set) the value of the length property of A to ToUint32(P)+1.
32 11. Return.
33 12. Compute ToUint32(V).
34 13. For every integer k that is less than the value of the length property
35 of A but not less than Result(12), if A itself has a property (not an
36 inherited property) named ToString(k), then delete that property.
37 14. Set the value of property P of A to Result(12).
38 15. Return.
41 These are gTestcases from Waldemar, detailed in
42 http://scopus.mcom.com/bugsplat/show_bug.cgi?id=123552
44 Author: christine@netscape.com
45 Date: 15 June 1998
46 */
48 var SECTION = "15.4.5.1-2";
49 var VERSION = "ECMA_1";
50 startTest();
51 var TITLE = "Array [[Put]] (P,V)";
53 writeHeaderToLog( SECTION + " "+ TITLE);
55 var a = new Array();
57 AddCase( "3.00", "three" );
58 AddCase( "00010", "eight" );
59 AddCase( "37xyz", "thirty-five" );
60 AddCase("5000000000", 5)
61 AddCase( "-2", -3 );
63 new TestCase( SECTION,
64 "a[10]",
65 void 0,
66 a[10] );
68 new TestCase( SECTION,
69 "a[3]",
70 void 0,
71 a[3] );
73 a[4] = "four";
75 new TestCase( SECTION,
76 "a[4] = \"four\"; a[4]",
77 "four",
78 a[4] );
80 new TestCase( SECTION,
81 "a[\"4\"]",
82 "four",
83 a["4"] );
85 new TestCase( SECTION,
86 "a[\"4.00\"]",
87 void 0,
88 a["4.00"] );
90 new TestCase( SECTION,
91 "a.length",
92 5,
93 a.length );
96 a["5000000000"] = 5;
98 new TestCase( SECTION,
99 "a[\"5000000000\"] = 5; a.length",
100 5,
101 a.length );
103 new TestCase( SECTION,
104 "a[\"-2\"] = -3; a.length",
105 5,
106 a.length );
108 test();
110 function AddCase ( arg, value ) {
112 a[arg] = value;
114 new TestCase( SECTION,
115 "a[\"" + arg + "\"] = "+ value +"; a.length",
116 0,
117 a.length );
118 }