| 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-array.from |
| 5 |
es6id: 22.1.2.1 |
| 6 |
description: Error invoking map function (traversed via iterator) |
| 7 |
info: | |
| 8 |
[...] |
| 9 |
6. If usingIterator is not undefined, then |
| 10 |
[...] |
| 11 |
g. Repeat |
| 12 |
[...] |
| 13 |
vii. If mapping is true, then |
| 14 |
1. Let mappedValue be Call(mapfn, T, «nextValue, k»). |
| 15 |
2. If mappedValue is an abrupt completion, return |
| 16 |
IteratorClose(iterator, mappedValue). |
| 17 |
features: [Symbol.iterator] |
| 18 |
---*/ |
| 19 |
|
| 20 |
var closeCount = 0; |
| 21 |
var mapFn = function() { |
| 22 |
throw new Test262Error(); |
| 23 |
}; |
| 24 |
var items = {}; |
| 25 |
items[Symbol.iterator] = function() { |
| 26 |
return { |
| 27 |
return: function() { |
| 28 |
closeCount += 1; |
| 29 |
}, |
| 30 |
next: function() { |
| 31 |
return { |
| 32 |
done: false |
| 33 |
}; |
| 34 |
} |
| 35 |
}; |
| 36 |
}; |
| 37 |
|
| 38 |
assert.throws(Test262Error, function() { |
| 39 |
Array.from(items, mapFn); |
| 40 |
}); |
| 41 |
|
| 42 |
assert.sameValue(closeCount, 1); |