| 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 |
---*/ |
| 14 |
|
| 15 |
var o = {}; |
| 16 |
var desc; |
| 17 |
|
| 18 |
Reflect.defineProperty(o, 'p1', { |
| 19 |
value: 42, |
| 20 |
writable: true, |
| 21 |
enumerable: true |
| 22 |
}); |
| 23 |
|
| 24 |
assert.sameValue(o.p1, 42); |
| 25 |
|
| 26 |
verifyWritable(o, 'p1'); |
| 27 |
verifyNotConfigurable(o, 'p1'); |
| 28 |
verifyEnumerable(o, 'p1'); |
| 29 |
|
| 30 |
var f1 = function() {}; |
| 31 |
var f2 = function() {}; |
| 32 |
Reflect.defineProperty(o, 'p2', { |
| 33 |
get: f1, |
| 34 |
set: f2 |
| 35 |
}); |
| 36 |
|
| 37 |
desc = Object.getOwnPropertyDescriptor(o, 'p2'); |
| 38 |
assert.sameValue(desc.get, f1); |
| 39 |
assert.sameValue(desc.set, f2); |