define-properties.js (883B)
1 // Copyright (C) 2015 the V8 project authors. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 /*--- 4 es6id: 26.1.3 5 description: > 6 Define properties from the attributes object. 7 info: | 8 26.1.3 Reflect.defineProperty ( target, propertyKey, attributes ) 9 10 ... 11 6. Return target.[[DefineOwnProperty]](key, desc). 12 includes: [propertyHelper.js] 13 features: [Reflect] 14 ---*/ 15 16 var o = {}; 17 var desc; 18 19 Reflect.defineProperty(o, 'p1', { 20 value: 42, 21 writable: true, 22 enumerable: true 23 }); 24 25 assert.sameValue(o.p1, 42); 26 27 verifyWritable(o, 'p1'); 28 verifyNotConfigurable(o, 'p1'); 29 verifyEnumerable(o, 'p1'); 30 31 var f1 = function() {}; 32 var f2 = function() {}; 33 Reflect.defineProperty(o, 'p2', { 34 get: f1, 35 set: f2 36 }); 37 38 desc = Object.getOwnPropertyDescriptor(o, 'p2'); 39 assert.sameValue(desc.get, f1); 40 assert.sameValue(desc.set, f2); 41 42 reportCompare(0, 0);