map-iterable-empty-does-not-call-set.js (777B)
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 esid: sec-map-iterable 5 description: > 6 A Map constructed with an empty iterable argument does not call set. 7 info: | 8 Map ( [ iterable ] ) 9 10 When the Map function is called with optional argument the following steps are 11 taken: 12 13 ... 14 8. If iter is undefined, return map. 15 9. Repeat 16 a. Let next be IteratorStep(iter). 17 b. ReturnIfAbrupt(next). 18 c. If next is false, return map. 19 ---*/ 20 21 var set = Map.prototype.set; 22 var counter = 0; 23 24 Map.prototype.set = function(value) { 25 counter++; 26 set.call(this, value); 27 }; 28 29 new Map([]); 30 31 assert.sameValue(counter, 0, '`Map.prototype.set` was not called.'); 32 33 reportCompare(0, 0);