Debian Codegraph @

js/src/tests/test262/language/statements/for-of/map-contract-expand.js

raw
1 // Copyright (C) 2015 the V8 project authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 description: Map entry removal and re-insertion during traversal using for..of
6 info: |
7 Entries removed from a Map instance during traversal should be visited if
8 they are re-inserted prior to iterator exhaustion.
9 es6id: 13.6.4
10 features: [Map]
11 ---*/
12
13 var map = new Map();
14 var iterationCount = 0;
15
16 var first = [0, 'a'];
17 var second = [1, 'b'];
18
19 map.set(0, 'a');
20 map.set(1, 'b');
21
22 for (var x of map) {
23 assert.sameValue(x[0], first[0]);
24 assert.sameValue(x[1], first[1]);
25
26 first = second;
27 second = null;
28
29 if (first !== null) {
30 map.delete(1);
31 map.set(1, 'b');
32 }
33
34 iterationCount += 1;
35 }
36
37 assert.sameValue(iterationCount, 2);
38
39 reportCompare(0, 0);