summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Promise/race/S25.4.4.3_A4.1_T1.js
blob: e4602242f2e74822bf9ef4c3335f9499bb3f0e1e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// |reftest| async
// Copyright 2014 Cubane Canada, Inc.  All rights reserved.
// See LICENSE for details.

/*---
es6id: S25.4.4.3_A4.1_T1
author: Sam Mikes
description: Promise.race rejects if IteratorStep throws
features: [Symbol.iterator]
flags: [async]
---*/

var iterThrows = {};
var error = new Test262Error();
iterThrows[Symbol.iterator] = function() {
  return {
    next: function() {
      throw error;
    }
  };
};

Promise.race(iterThrows).then(function() {
  throw new Test262Error('Promise unexpectedly fulfilled: Promise.race(iterThrows) should throw TypeError');
}, function(reason) {
  assert.sameValue(reason, error, 'The value of reason is expected to equal the value of error');
}).then($DONE, $DONE);