|
1 /// Copyright (c) 2012 Ecma International. All rights reserved. |
|
2 /// Ecma International makes this code available under the terms and conditions set |
|
3 /// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the |
|
4 /// "Use Terms"). Any redistribution of this code must retain the above |
|
5 /// copyright and this notice and otherwise comply with the Use Terms. |
|
6 /** |
|
7 * @path ch10/10.6/10.6-11-b-1.js |
|
8 * @description Arguments Object has index property '0' as its own property, it shoulde be writable, enumerable, configurable and does not invoke the setter defined on Object.prototype[0] (Step 11.b) |
|
9 */ |
|
10 |
|
11 |
|
12 function testcase() { |
|
13 try { |
|
14 var data = "data"; |
|
15 var getFunc = function () { |
|
16 return data; |
|
17 }; |
|
18 |
|
19 var setFunc = function (value) { |
|
20 data = value; |
|
21 }; |
|
22 |
|
23 Object.defineProperty(Object.prototype, "0", { |
|
24 get: getFunc, |
|
25 set: setFunc, |
|
26 configurable: true |
|
27 }); |
|
28 |
|
29 var argObj = (function () { return arguments })(1); |
|
30 |
|
31 var verifyValue = false; |
|
32 verifyValue = (argObj[0] === 1); |
|
33 |
|
34 var verifyEnumerable = false; |
|
35 for (var p in argObj) { |
|
36 if (p === "0" && argObj.hasOwnProperty("0")) { |
|
37 verifyEnumerable = true; |
|
38 } |
|
39 } |
|
40 |
|
41 var verifyWritable = false; |
|
42 argObj[0] = 1001; |
|
43 verifyWritable = (argObj[0] === 1001); |
|
44 |
|
45 var verifyConfigurable = false; |
|
46 delete argObj[0]; |
|
47 verifyConfigurable = argObj.hasOwnProperty("0"); |
|
48 |
|
49 return verifyValue && verifyWritable && verifyEnumerable && !verifyConfigurable && data === "data"; |
|
50 } finally { |
|
51 delete Object.prototype[0]; |
|
52 } |
|
53 } |
|
54 runTestCase(testcase); |