Debian Codegraph @

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