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_A6.2_T1
|
2014-10-23 19:58:31 +02:00
|
|
|
author: Sam Mikes
|
|
|
|
description: Promise.race([p1]) settles immediately
|
2017-06-23 17:06:32 +02:00
|
|
|
includes: [promiseHelper.js]
|
2016-02-12 18:59:51 +01:00
|
|
|
flags: [async]
|
2014-10-23 19:58:31 +02:00
|
|
|
---*/
|
|
|
|
|
|
|
|
var sequence = [];
|
|
|
|
|
|
|
|
var p1 = Promise.reject(1),
|
2018-02-15 21:11:21 +01:00
|
|
|
p = Promise.race([p1]);
|
2014-10-23 19:58:31 +02:00
|
|
|
|
|
|
|
sequence.push(1);
|
|
|
|
|
2018-02-15 21:11:21 +01:00
|
|
|
p.then(function() {
|
2021-07-21 21:48:13 +02:00
|
|
|
throw new Test262Error("Should not fulfill.");
|
2018-02-15 21:11:21 +01:00
|
|
|
}, function() {
|
|
|
|
sequence.push(4);
|
2021-08-18 17:44:54 +02:00
|
|
|
assert.sameValue(sequence.length, 4, 'The value of sequence.length is expected to be 4');
|
2020-06-24 21:18:35 +02:00
|
|
|
checkSequence(sequence, "This happens second");
|
2014-10-23 19:58:31 +02:00
|
|
|
}).catch($DONE);
|
|
|
|
|
2018-02-15 21:11:21 +01:00
|
|
|
Promise.resolve().then(function() {
|
|
|
|
sequence.push(3);
|
2021-08-18 17:44:54 +02:00
|
|
|
assert.sameValue(sequence.length, 3, 'The value of sequence.length is expected to be 3');
|
2018-02-15 21:11:21 +01:00
|
|
|
checkSequence(sequence, "This happens first");
|
|
|
|
}).then(function() {
|
|
|
|
sequence.push(5);
|
2021-08-18 17:44:54 +02:00
|
|
|
assert.sameValue(sequence.length, 5, 'The value of sequence.length is expected to be 5');
|
2018-02-15 21:11:21 +01:00
|
|
|
checkSequence(sequence, "This happens third");
|
2014-10-23 19:58:31 +02:00
|
|
|
}).then($DONE, $DONE);
|
|
|
|
|
|
|
|
sequence.push(2);
|