Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/Object/defineProperty/15.2.3.6-4-339-4.js

raw
1 // Copyright (c) 2012 Ecma International. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 es5id: 15.2.3.6-4-339-4
6 description: >
7 Object.defineProperty - Updating indexed data property 'P' with
8 attributes [[Writable]]: true, [[Enumerable]]: true,
9 [[Configurable]]: false to an accessor property does not succeed,
10 'O' is an Arguments object (8.12.9 - step 9.a)
11 ---*/
12
13 var obj = (function() {
14 return arguments;
15 }());
16
17 Object.defineProperty(obj, "0", {
18 value: 2010,
19 writable: true,
20 enumerable: true,
21 configurable: false
22 });
23 var propertyDefineCorrect = obj.hasOwnProperty("0");
24 var desc1 = Object.getOwnPropertyDescriptor(obj, "0");
25
26 function getFunc() {
27 return 20;
28 }
29 assert.throws(TypeError, function() {
30 Object.defineProperty(obj, "0", {
31 get: getFunc
32 });
33 });
34 var desc2 = Object.getOwnPropertyDescriptor(obj, "0");
35 assert(propertyDefineCorrect, 'propertyDefineCorrect !== true');
36 assert.sameValue(desc1.value, 2010, 'desc1.value');
37 assert.sameValue(obj[0], 2010, 'obj[0]');
38 assert.sameValue(typeof desc2.get, "undefined", 'typeof desc2.get');