Add value/key sign swap for Set.add and Map.set methods (#3681)

See also: ECMA-262 v6, 23.2.3.1 step 6 and 23.1.3.9 step 6

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
This commit is contained in:
Szilagyi Adam
2020-05-04 14:00:36 +02:00
committed by GitHub
parent 48e7b01fe9
commit 1a72e070c8
3 changed files with 50 additions and 2 deletions
+10
View File
@@ -147,3 +147,13 @@ try {
} catch(e){}
assert(closed === true);
var map = new Map();
map.set(-0, "foo");
var k;
map.forEach(function (value, key) {
k = 1 / key;
});
assert(k === Infinity);
assert(map.get(+0) === "foo");
+10
View File
@@ -126,3 +126,13 @@ s.forEach(function(value, key, thisArg) {
assert (typeof thisArg === "object");
assert(thisArg === s);
});
var set = new Set();
set.add(-0);
var k;
set.forEach(function (value) {
k = 1 / value;
});
assert(k === Infinity);
assert(set.has(+0) === true);