Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/Object/defineProperty/15.2.3.6-4-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 info: |
6 Step 4 of defineProperty calls the [[DefineOwnProperty]] internal method
7 of O to define the property. For newly defined accessor properties, attributes
8 missing from desc should have values set to the defaults from 8.6.1.
9 es5id: 15.2.3.6-4-3
10 description: >
11 Object.defineProperty sets missing attributes to their default
12 values (accessor)(8.12.9 step 4.b.i)
13 ---*/
14
15 var o = {};
16
17 var getter = function() {
18 return 1;
19 };
20 var desc = {
21 get: getter
22 };
23
24 Object.defineProperty(o, "foo", desc);
25
26 var propDesc = Object.getOwnPropertyDescriptor(o, "foo");
27
28 assert.sameValue(typeof(propDesc.get), "function", 'typeof(propDesc.get)');
29 assert.sameValue(propDesc.get, getter, 'propDesc.get'); // the getter must be the function that was provided
30 assert.sameValue(propDesc.set, undefined, 'propDesc.set'); // undefined by default
31 assert.sameValue(propDesc.enumerable, false, 'propDesc.enumerable'); // false by default
32 assert.sameValue(propDesc.configurable, false, 'propDesc.configurable'); // false by default