summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Object/getOwnPropertyDescriptors/symbols-included.js
blob: 8b5fe011fca91770b97fc327f118eb447b0cb4ea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Copyright (C) 2016 Jordan Harband. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
description: Object.getOwnPropertyDescriptors includes Symbol keys.
esid: sec-object.getownpropertydescriptors
author: Jordan Harband
features: [Symbol]
---*/

var value = {};
var enumSym = Symbol('enum');
var nonEnumSym = Symbol('nonenum');
var symValue = Symbol('value');

var obj = {
  key: symValue
};
obj[enumSym] = value;
Object.defineProperty(obj, nonEnumSym, {
  writable: true,
  enumerable: false,
  configurable: true,
  value: value
});

var result = Object.getOwnPropertyDescriptors(obj);

assert.sameValue(Object.keys(result).length, 1, 'obj has 1 string-keyed descriptor');
assert.sameValue(Object.getOwnPropertySymbols(result).length, 2, 'obj has 2 symbol-keyed descriptors');

assert.sameValue(result.key.configurable, true, 'result.key is configurable');
assert.sameValue(result.key.enumerable, true, 'result.key is enumerable');
assert.sameValue(result.key.writable, true, 'result.key is writable');
assert.sameValue(result.key.value, symValue, 'result.key has value symValue');

assert.sameValue(result[enumSym].configurable, true, 'result[enumSym] is configurable');
assert.sameValue(result[enumSym].enumerable, true, 'result[enumSym] is enumerable');
assert.sameValue(result[enumSym].writable, true, 'result[enumSym] is writable');
assert.sameValue(result[enumSym].value, value, 'result[enumSym] has value `value`');

assert.sameValue(result[nonEnumSym].configurable, true, 'result[nonEnumSym] is configurable');
assert.sameValue(result[nonEnumSym].enumerable, false, 'result[nonEnumSym] is not enumerable');
assert.sameValue(result[nonEnumSym].writable, true, 'result[nonEnumSym] is writable');
assert.sameValue(result[nonEnumSym].value, value, 'result[nonEnumSym] has value `value`');

reportCompare(0, 0);