| 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 |
Return IteratorClose(iter, status) if fail on adding value on constructing. |
| 8 |
info: | |
| 9 |
WeakMap ( [ iterable ] ) |
| 10 |
|
| 11 |
... |
| 12 |
9. Repeat |
| 13 |
k. Let status be Call(adder, map, «k.[[value]], v.[[value]]»). |
| 14 |
l. If status is an abrupt completion, return IteratorClose(iter, status). |
| 15 |
features: [Symbol.iterator] |
| 16 |
---*/ |
| 17 |
|
| 18 |
var count = 0; |
| 19 |
var iterable = {}; |
| 20 |
iterable[Symbol.iterator] = function() { |
| 21 |
return { |
| 22 |
next: function() { |
| 23 |
return { |
| 24 |
value: [], |
| 25 |
done: false |
| 26 |
}; |
| 27 |
}, |
| 28 |
return: function() { |
| 29 |
count += 1; |
| 30 |
} |
| 31 |
}; |
| 32 |
}; |
| 33 |
WeakMap.prototype.set = function() { |
| 34 |
throw new Test262Error(); |
| 35 |
}; |
| 36 |
|
| 37 |
assert.throws(Test262Error, function() { |
| 38 |
new WeakMap(iterable); |
| 39 |
}); |
| 40 |
|
| 41 |
assert.sameValue( |
| 42 |
count, 1, |
| 43 |
'The iterator is closed when `WeakMap.prototype.set` throws an error.' |
| 44 |
); |