Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/Object/defineProperty/15.2.3.6-4-547-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-547-3
6 description: >
7 ES5 Attributes - Updating a named accessor property 'P' whose
8 [[Configurable]] attribute is false to a data property does not
9 succeed, 'A' is an Array object (8.12.9 step 9.a)
10 includes: [propertyHelper.js]
11 ---*/
12
13 var obj = [];
14
15 obj.verifySetFunc = "data";
16 var getFunc = function() {
17 return obj.verifySetFunc;
18 };
19
20 var setFunc = function(value) {
21 obj.verifySetFunc = value;
22 };
23
24 Object.defineProperty(obj, "prop", {
25 get: getFunc,
26 set: setFunc,
27 enumerable: true,
28 configurable: false
29 });
30 var desc1 = Object.getOwnPropertyDescriptor(obj, "prop");
31
32 try {
33 Object.defineProperty(obj, "prop", {
34 value: 1001
35 });
36
37 $ERROR("Expected an exception.");
38 } catch (e) {
39 var desc2 = Object.getOwnPropertyDescriptor(obj, "prop");
40
41 if (!desc1.hasOwnProperty("get")) {
42 $ERROR('Expected desc1.hasOwnProperty("get") to be true, actually ' + desc1.hasOwnProperty("get"));
43 }
44
45 if (desc2.hasOwnProperty("value")) {
46 $ERROR('Expected !desc2.hasOwnProperty("value") to be true, actually ' + !desc2.hasOwnProperty("value"));
47 }
48
49
50 verifyEqualTo(obj, "prop", getFunc());
51
52 verifyWritable(obj, "prop", "verifySetFunc");
53
54 verifyEnumerable(obj, "prop");
55
56 verifyNotConfigurable(obj, "prop");
57
58 if (!(e instanceof TypeError)) {
59 $ERROR("Expected TypeError, got " + e);
60 }
61
62 }