summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Set/bigint-number-same-value.js
blob: 23406648c3c91c94cf05cfaf1c2e6ca4a7e6f73d (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
// Copyright (C) 2021 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-set.prototype.add
description: >
  Observing the expected behavior of keys when a BigInt and Number have
  the same value.
info: |
  Set.prototype.add ( value )

  ...
  For each element e of entries, do
    If e is not empty and SameValueZero(e, value) is true, then
    Return S.
  If value is -0, set value to +0.
  Append value as the last element of entries.
  ...

features: [BigInt]
---*/

const number = 9007199254740991;
const bigint = 9007199254740991n;

const s = new Set([
  number,
  bigint,
]);

assert.sameValue(s.size, 2);
assert.sameValue(s.has(number), true);
assert.sameValue(s.has(bigint), true);

s.delete(number);
assert.sameValue(s.size, 1);
assert.sameValue(s.has(number), false);
s.delete(bigint);
assert.sameValue(s.size, 0);
assert.sameValue(s.has(bigint), false);

s.add(number);
assert.sameValue(s.size, 1);
s.add(bigint);
assert.sameValue(s.size, 2);

reportCompare(0, 0);