summaryrefslogtreecommitdiff
path: root/test/built-ins/TypedArrays/internals/GetOwnProperty/index-prop-desc.js
blob: 0771ae51ec4a68ab1eff00f2856c6a13b0d0bcd1 (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
// 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-getownproperty-p
description: >
  Returns a descriptor object from an index property
info: |
  9.4.5.1 [[GetOwnProperty]] ( P )

  ...
  3. If Type(P) is String, then
    a. Let numericIndex be ! CanonicalNumericIndexString(P).
    b. If numericIndex is not undefined, then
      ...
      iii. Return a PropertyDescriptor{[[Value]]: value, [[Writable]]: true,
      [[Enumerable]]: true, [[Configurable]]: false}.
  ...
includes: [testTypedArray.js, propertyHelper.js]
features: [TypedArray]
---*/

testWithTypedArrayConstructors(function(TA, N) {
  var sample = new TA(N([42, 43]));

  var desc0 = Object.getOwnPropertyDescriptor(sample, 0);
  assert.sameValue(desc0.value, N(42), "value", "desc0.value === 42");
  assert.sameValue(desc0.writable, true, "index descriptor is writable [0]");
  verifyEnumerable(sample, "0", "index descriptor is enumerable [0]");
  verifyNotConfigurable(sample, "0", "index descriptor is not configurable [0]");

  var desc1 = Object.getOwnPropertyDescriptor(sample, 1);
  assert.sameValue(desc1.value, N(43), "value", "desc1.value === 43");
  assert.sameValue(desc1.writable, true, "index descriptor is writable [1]");
  verifyEnumerable(sample, "1", "index descriptor is enumerable [1]");
  verifyNotConfigurable(sample, "1", "index descriptor is not configurable [1]");
});