mirror of https://github.com/tc39/test262.git
test: expected behavior when bigint and number have "same" value
This commit is contained in:
parent
44b224d388
commit
4fa52c8d2d
|
@ -0,0 +1,44 @@
|
|||
// Copyright (C) 2021 Rick Waldron. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-map.prototype.set
|
||||
description: >
|
||||
Observing the expected behavior of keys when a BigInt and Number have
|
||||
the same value.
|
||||
info: |
|
||||
Map.prototype.set ( key , value )
|
||||
|
||||
...
|
||||
Let p be the Record {[[key]]: key, [[value]]: value}.
|
||||
Append p as the last element of entries.
|
||||
...
|
||||
|
||||
features: [BigInt]
|
||||
---*/
|
||||
|
||||
const number = 9007199254740991;
|
||||
const bigint = 9007199254740991n;
|
||||
|
||||
const m = new Map([
|
||||
[number, number],
|
||||
[bigint, bigint],
|
||||
]);
|
||||
|
||||
assert.sameValue(m.size, 2);
|
||||
assert.sameValue(m.has(number), true);
|
||||
assert.sameValue(m.has(bigint), true);
|
||||
|
||||
assert.sameValue(m.get(number), number);
|
||||
assert.sameValue(m.get(bigint), bigint);
|
||||
|
||||
m.delete(number);
|
||||
assert.sameValue(m.size, 1);
|
||||
assert.sameValue(m.has(number), false);
|
||||
m.delete(bigint);
|
||||
assert.sameValue(m.size, 0);
|
||||
assert.sameValue(m.has(bigint), false);
|
||||
|
||||
m.set(number, number);
|
||||
assert.sameValue(m.size, 1);
|
||||
m.set(bigint, bigint);
|
||||
assert.sameValue(m.size, 2);
|
|
@ -0,0 +1,44 @@
|
|||
// 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);
|
|
@ -10,7 +10,7 @@ info: |
|
|||
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𝔽.
|
||||
If value is -0, set value to +0.
|
||||
Append value as the last element of entries.
|
||||
...
|
||||
|
||||
|
|
Loading…
Reference in New Issue