2014-10-23 19:58:31 +02:00
|
|
|
// Copyright 2014 Cubane Canada, Inc. All rights reserved.
|
|
|
|
// See LICENSE for details.
|
|
|
|
|
|
|
|
/*---
|
2015-02-10 22:01:39 +01:00
|
|
|
es6id: S25.4.4.3_A7.3_T1
|
2014-10-23 19:58:31 +02:00
|
|
|
author: Sam Mikes
|
|
|
|
description: Promise.race([p1, p2]) settles when first settles
|
2016-02-12 18:59:51 +01:00
|
|
|
flags: [async]
|
2014-10-23 19:58:31 +02:00
|
|
|
---*/
|
|
|
|
|
|
|
|
var resolveP1, rejectP2,
|
2018-02-15 21:11:21 +01:00
|
|
|
p1 = new Promise(function(resolve) {
|
|
|
|
resolveP1 = resolve;
|
|
|
|
}),
|
|
|
|
p2 = new Promise(function(resolve, reject) {
|
|
|
|
rejectP2 = reject;
|
|
|
|
});
|
2014-10-23 19:58:31 +02:00
|
|
|
|
|
|
|
rejectP2(new Error("Promise.race should not see this if P1 already resolved"));
|
|
|
|
resolveP1(1);
|
|
|
|
|
2021-08-18 17:44:54 +02:00
|
|
|
Promise.race([p1, p2]).then(function(result) {
|
|
|
|
assert.sameValue(result, 1, 'The value of result is expected to be 1');
|
2014-10-23 19:58:31 +02:00
|
|
|
}).then($DONE, $DONE);
|