map.js (806B)
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 traversal using for..of 6 info: | 7 Map instances should be able to be traversed using a `for...of` loop. 8 es6id: 13.6.4 9 features: [Map] 10 ---*/ 11 12 var map = new Map(); 13 var obj = {}; 14 var iterationCount = 0; 15 16 var first = [0, 'a']; 17 var second = [true, false]; 18 var third = [null, undefined]; 19 var fourth = [NaN, obj]; 20 21 map.set(0, 'a'); 22 map.set(true, false); 23 map.set(null, undefined); 24 map.set(NaN, obj); 25 26 for (var x of map) { 27 assert.sameValue(x[0], first[0]); 28 assert.sameValue(x[1], first[1]); 29 first = second; 30 second = third; 31 third = fourth; 32 fourth = null; 33 iterationCount += 1; 34 } 35 36 assert.sameValue(iterationCount, 4); 37 38 reportCompare(0, 0);