| 1 |
// Copyright 2014 Cubane Canada, Inc. All rights reserved. |
| 2 |
// See LICENSE for details. |
| 3 |
|
| 4 |
/*--- |
| 5 |
info: | |
| 6 |
Promise.race rejects when GetIterator() returns an abrupt completion |
| 7 |
4. Let iterator be GetIterator(iterable). |
| 8 |
5. IfAbruptRejectPromise(iterator, promiseCapability) |
| 9 |
es6id: S25.4.4.3_A2.2_T3 |
| 10 |
author: Sam Mikes |
| 11 |
description: Promise.race rejects if GetIterator throws |
| 12 |
features: [Symbol.iterator] |
| 13 |
flags: [async] |
| 14 |
---*/ |
| 15 |
|
| 16 |
var iterThrows = {}; |
| 17 |
Object.defineProperty(iterThrows, Symbol.iterator, { |
| 18 |
get: function() { |
| 19 |
throw new Error("abrupt completion"); |
| 20 |
} |
| 21 |
}); |
| 22 |
|
| 23 |
Promise.race(iterThrows).then(function() { |
| 24 |
$ERROR('Promise unexpectedly fulfilled: Promise.race(iterThrows) should throw'); |
| 25 |
}, function(err) { |
| 26 |
if (!(err instanceof Error)) { |
| 27 |
$ERROR('Expected Promise to be rejected with an error, got ' + err); |
| 28 |
} |
| 29 |
}).then($DONE, $DONE); |