Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/Object/defineProperty/15.2.3.6-4-245.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-245
6 description: >
7 Object.defineProperty - 'O' is an Array, 'name' is an array index
8 named property, 'name' is data property and 'desc' is data
9 descriptor, and the [[Configurable]] attribute value of 'name' is
10 false, test TypeError is thrown if the [[Writable]] attribute
11 value of 'name' is false, and the type of the [[Value]] field of
12 'desc' is different from the type of the [[Value]] attribute value
13 of 'name' (15.4.5.1 step 4.c)
14 includes: [propertyHelper.js]
15 ---*/
16
17
18 var arrObj = [];
19
20 Object.defineProperty(arrObj, "1", {
21 value: 3,
22 writable: false,
23 configurable: false
24 });
25
26 try {
27 Object.defineProperty(arrObj, "1", {
28 value: "abc"
29 });
30 $ERROR("Expected an exception.");
31 } catch (e) {
32 verifyEqualTo(arrObj, "1", 3);
33
34 verifyNotWritable(arrObj, "1");
35
36 verifyNotEnumerable(arrObj, "1");
37
38 verifyNotConfigurable(arrObj, "1");
39
40 if (!(e instanceof TypeError)) {
41 $ERROR("Expected TypeError, got " + e);
42 }
43
44 }