Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/Object/defineProperty/15.2.3.6-4-97.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-97
6 description: >
7 Object.defineProperty will throw TypeError when name.configurable
8 = false, name.[[Set]] is undefined, desc.[[Set]] refers to an
9 object (8.12.9 step 11.a.i)
10 includes: [propertyHelper.js]
11 ---*/
12
13
14 var obj = {};
15
16 function getFunc() {
17 return "property";
18 }
19
20 Object.defineProperty(obj, "property", {
21 get: getFunc,
22 configurable: false
23 });
24
25 try {
26 Object.defineProperty(obj, "property", {
27 get: getFunc,
28 set: function() {},
29 configurable: false
30 });
31
32 $ERROR("Expected an exception.");
33 } catch (e) {
34 verifyEqualTo(obj, "property", getFunc());
35
36 verifyNotEnumerable(obj, "property");
37
38 verifyNotConfigurable(obj, "property");
39
40 if (!(e instanceof TypeError)) {
41 $ERROR("Expected TypeError, got " + e);
42 }
43
44 }