Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/Object/defineProperty/15.2.3.6-4-540-1.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-540-1
6 description: >
7 Object.defineProperty fails to update [[Get]] and [[Set]]
8 attributes of a named accessor property 'P' whose [[Configurable]]
9 attribute is false and throws TypeError exception, 'O' is an
10 Object object (8.12.9 step 11.a)
11 includes: [propertyHelper.js]
12 ---*/
13
14 var obj = {};
15
16 obj.verifySetFunction = "data";
17 var getFunc = function() {
18 return obj.verifySetFunction;
19 };
20 var setFunc = function(value) {
21 obj.verifySetFunction = value;
22 };
23 Object.defineProperty(obj, "property", {
24 get: getFunc,
25 set: setFunc,
26 configurable: false
27 });
28
29 var result = false;
30 try {
31 Object.defineProperty(obj, "property", {
32 get: function() {
33 return 100;
34 }
35 });
36 } catch (e) {
37 result = e instanceof TypeError;
38 verifyEqualTo(obj, "property", getFunc());
39
40 verifyWritable(obj, "property", "verifySetFunction");
41
42 verifyNotEnumerable(obj, "property");
43
44 verifyNotConfigurable(obj, "property");
45 }
46
47 try {
48 Object.defineProperty(obj, "property", {
49 set: function(value) {
50 obj.verifySetFunction1 = value;
51 }
52 });
53 } catch (e) {
54 if (!result) {
55 $ERROR('Expected result to be true, actually ' + result);
56 }
57
58 verifyEqualTo(obj, "property", getFunc());
59
60 verifyWritable(obj, "property", "verifySetFunction");
61
62 verifyNotEnumerable(obj, "property");
63
64 verifyNotConfigurable(obj, "property");
65
66 if (!(e instanceof TypeError)) {
67 $ERROR("Expected TypeError, got " + e);
68 }
69
70 }