Debian Codegraph @

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