Debian Codegraph @

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