getter-prop-desc.js (1325B)
1 // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 /*--- 4 esid: sec-object-initializer-runtime-semantics-evaluation 5 es6id: 12.2.6.8 6 description: Property descriptor of "set" accessor methods 7 info: | 8 ObjectLiteral: 9 { PropertyDefinitionList } 10 { PropertyDefinitionList , } 11 12 1. Let obj be ObjectCreate(%ObjectPrototype%). 13 2. Let status be the result of performing PropertyDefinitionEvaluation of 14 PropertyDefinitionList with arguments obj and true. 15 3. ReturnIfAbrupt(status). 16 4. Return obj. 17 18 14.3.8 Runtime Semantics: PropertyDefinitionEvaluation 19 20 MethodDefinition : get PropertyName ( ) { FunctionBody} 21 22 [...] 23 9. Let desc be the PropertyDescriptor{[[Get]]: closure, [[Enumerable]]: 24 enumerable, [[Configurable]]: true}. 25 [...] 26 includes: [propertyHelper.js] 27 ---*/ 28 29 var obj = { get m() { return 1234; } }; 30 var desc = Object.getOwnPropertyDescriptor(obj, 'm'); 31 32 verifyProperty(obj, 'm', { 33 enumerable: true, 34 configurable: true, 35 }); 36 37 assert.sameValue(desc.value, undefined, '`value` field'); 38 assert.sameValue(desc.set, undefined, '`set` field'); 39 assert.sameValue(typeof desc.get, 'function', 'type of `get` field'); 40 assert.sameValue(desc.get(), 1234, '`get` function return value'); 41 42 reportCompare(0, 0);