summaryrefslogtreecommitdiff
path: root/test/built-ins/TypedArrays/internals/DefineOwnProperty/BigInt/key-is-not-integer.js
blob: 0d3d3cc7945dec01d44704d288d6518983a9db9d (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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
// 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: >
  Returns false if numericIndex is not an integer
info: |
  9.4.5.3 [[DefineOwnProperty]] ( P, Desc)
  ...
  3. If Type(P) is String, then
    a. Let numericIndex be ! CanonicalNumericIndexString(P).
    b. If numericIndex is not undefined, then
      i. If IsInteger(numericIndex) is false, return false.
  ...
includes: [testBigIntTypedArray.js]
features: [BigInt, Reflect, TypedArray]
---*/

testWithBigIntTypedArrayConstructors(function(TA) {
  var sample = new TA(2);

  assert.sameValue(
    Reflect.defineProperty(sample, "0.1", {
      value: 42,
      configurable: false,
      enumerable: true,
      writable: true
    }),
    false,
    "0.1"
  );
  assert.sameValue(sample[0], convertToBigInt(0), "'0.1' - does not change the value for [0]");
  assert.sameValue(
    sample["0.1"],
    undefined,
    "'0.1' - does not define a value for ['0.1']"
  );

  assert.sameValue(
    Reflect.defineProperty(sample, "0.000001", {
      value: 42,
      configurable: false,
      enumerable: true,
      writable: true
    }),
    false,
    "0.000001"
  );
  assert.sameValue(
    sample[0], convertToBigInt(0),
    "'0.000001' - does not change the value for [0]"
  );
  assert.sameValue(
    sample["0.000001"],
    undefined,
    "'0.000001' - does not define a value for ['0.000001']"
  );

  assert.sameValue(
    Reflect.defineProperty(sample, "1.1", {
      value: 42,
      configurable: false,
      enumerable: true,
      writable: true
    }),
    false,
    "1.1"
  );
  assert.sameValue(sample[1], convertToBigInt(0), "'1.1' - does not change the value for [1]");
  assert.sameValue(
    sample["1.1"],
    undefined,
    "'1.1' - does not define a value for ['1.1']"
  );

  assert.sameValue(
    Reflect.defineProperty(sample, "Infinity", {
      value: 42,
      configurable: false,
      enumerable: true,
      writable: true
    }),
    false,
    "Infinity"
  );
  assert.sameValue(
    sample[0], convertToBigInt(0),
    "'Infinity' - does not change the value for [0]"
  );
  assert.sameValue(
    sample[1], convertToBigInt(0),
    "'Infinity' - does not change the value for [1]"
  );
  assert.sameValue(
    sample["Infinity"],
    undefined,
    "'Infinity' - does not define a value for ['Infinity']"
  );

  assert.sameValue(
    Reflect.defineProperty(sample, "-Infinity", {
      value: 42,
      configurable: false,
      enumerable: true,
      writable: true
    }),
    false,
    "-Infinity"
  );
  assert.sameValue(
    sample[0], convertToBigInt(0),
    "'-Infinity' - does not change the value for [0]"
  );
  assert.sameValue(
    sample[1], convertToBigInt(0),
    "'-Infinity' - does not change the value for [1]"
  );
  assert.sameValue(
    sample["-Infinity"],
    undefined,
    "'-Infinity' - does not define a value for ['-Infinity']"
  );

});