summaryrefslogtreecommitdiff
path: root/test/built-ins/TypedArrays/internals/DefineOwnProperty/BigInt/key-is-symbol.js
blob: 08c9d10647b51dcf7120b2d89349bbea8286c154 (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
48
49
50
51
52
53
54
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-integer-indexed-exotic-objects-defineownproperty-p-desc
description: >
  Define an ordinary property value if key is a Symbol
info: |
  9.4.5.3 [[DefineOwnProperty]] ( P, Desc)
  ...
  3. If Type(P) is String, then
    ...
  4. Return OrdinaryDefineOwnProperty(O, P, Desc).
  ...
includes: [testBigIntTypedArray.js, propertyHelper.js]
features: [BigInt, Reflect, Symbol, TypedArray]
---*/

testWithBigIntTypedArrayConstructors(function(TA) {
  var sample = new TA([42n, 43n]);

  var s1 = Symbol("foo");
  assert.sameValue(
    Reflect.defineProperty(sample, s1, {
      value: 42,
      configurable: true
    }),
    true,
    "return true after defining property"
  );

  assert.sameValue(sample[s1], 42);
  verifyNotWritable(sample, s1);
  verifyNotEnumerable(sample, s1);
  verifyConfigurable(sample, s1);

  var s2 = Symbol("bar");
  var fnset = function() {};
  var fnget = function() {};
  assert.sameValue(
    Reflect.defineProperty(sample, s2, {
      get: fnget,
      set: fnset,
      enumerable: true
    }),
    true,
    "return true after defining property"
  );

  var desc = Object.getOwnPropertyDescriptor(sample, s2);
  assert.sameValue(desc.get, fnget, "accessor's get");
  assert.sameValue(desc.set, fnset, "accessor's set");
  assert.sameValue(desc.enumerable, true);
  verifyNotConfigurable(sample, s2);
});