Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/Object/defineProperty/15.2.3.6-4-339-3.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-3
6 description: >
7 Object.defineProperty - Updating named data property 'P' with
8 attributes [[Writable]]: true, [[Enumerable]]: true,
9 [[Configurable]]: false to an accessor property does not succeed,
10 'A' is an Array object (8.12.9 - step 9.a)
11 ---*/
12
13 var obj = [];
14
15 Object.defineProperty(obj, "prop", {
16 value: 2010,
17 writable: true,
18 enumerable: true,
19 configurable: false
20 });
21 var propertyDefineCorrect = obj.hasOwnProperty("prop");
22 var desc1 = Object.getOwnPropertyDescriptor(obj, "prop");
23
24 function getFunc() {
25 return 20;
26 }
27 assert.throws(TypeError, function() {
28 Object.defineProperty(obj, "prop", {
29 get: getFunc
30 });
31 });
32 var desc2 = Object.getOwnPropertyDescriptor(obj, "prop");
33 assert(propertyDefineCorrect, 'propertyDefineCorrect !== true');
34 assert.sameValue(desc1.value, 2010, 'desc1.value');
35 assert.sameValue(obj.prop, 2010, 'obj.prop');
36 assert.sameValue(typeof desc2.get, "undefined", 'typeof desc2.get');