Debian Codegraph @

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