| 1 |
// Copyright (C) 2013 the V8 project authors. All rights reserved. |
| 2 |
// This code is governed by the BSD license found in the LICENSE file. |
| 3 |
/*--- |
| 4 |
es6id: 19.1.2.4 |
| 5 |
description: > |
| 6 |
Symbol used as property for configurable data property definition |
| 7 |
features: [Symbol] |
| 8 |
---*/ |
| 9 |
var sym = Symbol(); |
| 10 |
var obj = {}; |
| 11 |
|
| 12 |
|
| 13 |
Object.defineProperty(obj, sym, { |
| 14 |
value: 1, |
| 15 |
configurable: true |
| 16 |
}); |
| 17 |
|
| 18 |
assert.sameValue(sym in obj, true, "The result of `sym in obj` is `true`"); |
| 19 |
assert.sameValue( |
| 20 |
Object.hasOwnProperty.call(obj, sym), |
| 21 |
true, |
| 22 |
"`Object.hasOwnProperty.call(obj, sym)` returns `true`" |
| 23 |
); |
| 24 |
|
| 25 |
var desc = Object.getOwnPropertyDescriptor(obj, sym); |
| 26 |
|
| 27 |
assert.sameValue(desc.value, 1, "The value of `desc.value` is `1`"); |
| 28 |
assert.sameValue(desc.configurable, true, "The value of `desc.configurable` is `true`"); |
| 29 |
assert.sameValue(desc.writable, false, "The value of `desc.writable` is `false`"); |
| 30 |
assert.sameValue(desc.enumerable, false, "The value of `desc.enumerable` is `false`"); |
| 31 |
assert.sameValue( |
| 32 |
Object.prototype.propertyIsEnumerable.call(obj, sym), |
| 33 |
false, |
| 34 |
"`Object.prototype.propertyIsEnumerable.call(obj, sym)` returns `false`" |
| 35 |
); |
| 36 |
|
| 37 |
assert.sameValue(delete obj[sym], true, "The result of `delete obj[sym]` is `true`"); |
| 38 |
|
| 39 |
assert.sameValue( |
| 40 |
Object.getOwnPropertyDescriptor(obj, sym), |
| 41 |
undefined, |
| 42 |
"`Object.getOwnPropertyDescriptor(obj, sym)` returns `undefined`" |
| 43 |
); |