Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/WeakSet/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.4.1.1
5 esid: sec-weakset-iterable
6 description: >
7 Returns the new WeakSet adding the objects from the iterable parameter.
8 info: |
9 WeakSet ( [ iterable ] )
10
11 ...
12 9. Repeat
13 f. Let status be Call(adder, set, «nextValue»).
14 g. If status is an abrupt completion, return IteratorClose(iter, status).
15 includes: [compareArray.js]
16 ---*/
17
18 var first = {};
19 var second = {};
20 var added = [];
21 var add = WeakSet.prototype.add;
22 WeakSet.prototype.add = function(value) {
23 added.push(value);
24 return add.call(this, value);
25 };
26 var s = new WeakSet([first, second]);
27
28 assert.sameValue(added.length, 2, 'Called WeakSet#add for each object');
29 assert.sameValue(added[0], first, 'Adds object in order - first');
30 assert.sameValue(added[1], second, 'Adds object in order - second');