Debian Codegraph @

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