Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/Object/freeze/15.2.3.9-2-c-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.9-2-c-4
6 description: >
7 Object.freeze - all own properties of 'O' are not writable and not
8 configurable
9 includes: [propertyHelper.js]
10 ---*/
11
12 var obj = {};
13 var resultSetFun = false;
14
15 Object.defineProperty(obj, "foo1", {
16 value: 10,
17 writable: false,
18 enumerable: true,
19 configurable: false
20 });
21
22 function get_func() {
23 return 10;
24 }
25
26 function set_func() {
27 resultSetFun = true;
28 }
29
30 Object.defineProperty(obj, "foo2", {
31 get: get_func,
32 set: set_func,
33 enumerable: true,
34 configurable: true
35 });
36
37 Object.freeze(obj);
38
39 verifyEqualTo(obj, "foo2", 10);
40
41 verifyNotConfigurable(obj, "foo2");
42
43 obj.foo2 = 12;
44 if (!resultSetFun) {
45 $ERROR('Expected obj["foo2"] set() to be called, but was not.');
46 }
47
48 verifyEnumerable(obj, "foo2");
49
50 var desc1 = Object.getOwnPropertyDescriptor(obj, "foo1");
51 if (desc1.configurable || desc1.writable) {
52 $ERROR('Expected obj["foo1"] to be non-writable, non-configurable; actually ' + JSON.stringify(desc1));
53 }
54
55 var desc2 = Object.getOwnPropertyDescriptor(obj, "foo2");
56 if (desc2.configurable || desc2.writable) {
57 $ERROR('Expected obj["foo2"] to be non-writable, non-configurable; actually ' + JSON.stringify(desc2));
58 }
59
60 verifyEqualTo(obj, "foo1", 10);
61
62 verifyNotWritable(obj, "foo1");
63
64 verifyEnumerable(obj, "foo1");
65
66 verifyNotConfigurable(obj, "foo1");