bigint-number-same-value.js (1047B)
1 // Copyright (C) 2021 Rick Waldron. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 /*--- 4 esid: sec-set.prototype.add 5 description: > 6 Observing the expected behavior of keys when a BigInt and Number have 7 the same value. 8 info: | 9 Set.prototype.add ( value ) 10 11 ... 12 For each element e of entries, do 13 If e is not empty and SameValueZero(e, value) is true, then 14 Return S. 15 If value is -0, set value to +0. 16 Append value as the last element of entries. 17 ... 18 19 features: [BigInt] 20 ---*/ 21 22 const number = 9007199254740991; 23 const bigint = 9007199254740991n; 24 25 const s = new Set([ 26 number, 27 bigint, 28 ]); 29 30 assert.sameValue(s.size, 2); 31 assert.sameValue(s.has(number), true); 32 assert.sameValue(s.has(bigint), true); 33 34 s.delete(number); 35 assert.sameValue(s.size, 1); 36 assert.sameValue(s.has(number), false); 37 s.delete(bigint); 38 assert.sameValue(s.size, 0); 39 assert.sameValue(s.has(bigint), false); 40 41 s.add(number); 42 assert.sameValue(s.size, 1); 43 s.add(bigint); 44 assert.sameValue(s.size, 2); 45 46 reportCompare(0, 0);