summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/collections/Map-iterator-add-remove.js
blob: b71bfd18cf603a7e1b4cae30b86cb1b5349c505a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
// Removing and re-adding entries while an iterator is live causes the iterator to visit them again.

var map = new Map([['a', 1]]);
var n = 5;
for (let [k, v] of map) {
    assertEq(k, 'a');
    assertEq(v, 1);
    if (n === 0)
        break;
    map.delete('a');
    map.set('a', 1);
    n--;
}
assertEq(n, 0);