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