blob: 7ea91410d036b5ad29f58a3d4512f43c7be88d7b [file] [log] [blame]
keith_miller@apple.combcc77f22016-07-15 06:03:25 +00001// 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/*---
4es6id: 23.4.1.1
5description: >
6 Return IteratorClose(iter, status) if fail on adding value on constructing.
7info: >
8 WeakSet ( [ iterable ] )
9
10 ...
11 9. Repeat
12 f. Let status be Call(adder, set, «nextValue»).
13 g. If status is an abrupt completion, return IteratorClose(iter, status).
14---*/
15
16var count = 0;
17var iterable = {};
18iterable[Symbol.iterator] = function() {
19 return {
20 next: function() {
21 return { value: null, done: false };
22 },
23 return: function() {
24 count += 1;
25 }
26 };
27};
28WeakSet.prototype.add = function() { throw new Test262Error(); };
29
30assert.throws(Test262Error, function() {
31 new WeakSet(iterable);
32});
33
34assert.sameValue(
35 count, 1,
36 'The iterator is closed when `WeakSet.prototype.add` throws an error.'
37);