empty-iterable.js (808B)
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-weakmap-iterable 5 description: > 6 If the iterable argument is empty, return new WeakMap object. 7 info: | 8 23.3.1.1 WeakMap ( [ iterable ] ) 9 10 ... 11 9. Repeat 12 a. Let next be IteratorStep(iter). 13 b. ReturnIfAbrupt(next). 14 c. If next is false, return map. 15 ... 16 ---*/ 17 18 var counter = 0; 19 var set = WeakMap.prototype.set; 20 WeakMap.prototype.set = function(value) { 21 counter++; 22 return set.call(this, value); 23 }; 24 var map = new WeakMap([]); 25 26 assert.sameValue(Object.getPrototypeOf(map), WeakMap.prototype); 27 assert(map instanceof WeakMap); 28 assert.sameValue( 29 counter, 0, 30 'empty iterable does not call WeakMap.prototype.set' 31 ); 32 33 reportCompare(0, 0);