| 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 symbol properties. |
| 7 |
info: | |
| 8 |
26.1.3 Reflect.defineProperty ( target, propertyKey, attributes ) |
| 9 |
|
| 10 |
... |
| 11 |
2. Let key be ToPropertyKey(propertyKey). |
| 12 |
... |
| 13 |
|
| 14 |
7.1.14 ToPropertyKey ( argument ) |
| 15 |
|
| 16 |
... |
| 17 |
3. If Type(key) is Symbol, then |
| 18 |
a. Return key. |
| 19 |
... |
| 20 |
features: [Symbol] |
| 21 |
---*/ |
| 22 |
|
| 23 |
var o = {}; |
| 24 |
var desc; |
| 25 |
|
| 26 |
var s1 = Symbol('1'); |
| 27 |
|
| 28 |
Reflect.defineProperty(o, s1, { |
| 29 |
value: 42, |
| 30 |
writable: true, |
| 31 |
enumerable: true |
| 32 |
}); |
| 33 |
|
| 34 |
assert.sameValue(o[s1], 42); |
| 35 |
|
| 36 |
desc = Object.getOwnPropertyDescriptor(o, s1); |
| 37 |
|
| 38 |
assert.sameValue(desc.writable, true); |
| 39 |
assert.sameValue(desc.configurable, false); |
| 40 |
assert.sameValue(desc.enumerable, true); |
| 41 |
|
| 42 |
var s2 = Symbol('2'); |
| 43 |
|
| 44 |
var f1 = function() {}; |
| 45 |
var f2 = function() {}; |
| 46 |
Reflect.defineProperty(o, s2, { |
| 47 |
get: f1, |
| 48 |
set: f2 |
| 49 |
}); |
| 50 |
|
| 51 |
desc = Object.getOwnPropertyDescriptor(o, s2); |
| 52 |
assert.sameValue(desc.get, f1); |
| 53 |
assert.sameValue(desc.set, f2); |