mirror of
https://github.com/tc39/test262.git
synced 2025-07-23 22:15:24 +02:00
Merge pull request #462 from jugglinmike/improve-promise-coverage-reject
Improve Promise coverage: Promise Reject Function
This commit is contained in:
commit
9d48bb0875
39
test/built-ins/Promise/all/reject-deferred.js
Normal file
39
test/built-ins/Promise/all/reject-deferred.js
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
description: Rejecting through deferred invocation of the provided resolving function
|
||||||
|
es6id: 25.4.4.1
|
||||||
|
info: >
|
||||||
|
[...]
|
||||||
|
6. Let promiseCapability be NewPromiseCapability(C).
|
||||||
|
[...]
|
||||||
|
11. Let result be PerformPromiseAll(iteratorRecord, promiseCapability, C).
|
||||||
|
[...]
|
||||||
|
|
||||||
|
25.4.4.1.1 Runtime Semantics: PerformPromiseAll
|
||||||
|
[...]
|
||||||
|
6. Repeat
|
||||||
|
[...]
|
||||||
|
r. Let result be Invoke(nextPromise, "then", resolveElement,
|
||||||
|
promiseCapability.[[Reject]]»).
|
||||||
|
|
||||||
|
25.4.1.3.1 Promise Reject Functions
|
||||||
|
[...]
|
||||||
|
6. Return RejectPromise(promise, reason).
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var thenable = {
|
||||||
|
then: function(_, reject) {
|
||||||
|
new Promise(function(resolve) { resolve(); })
|
||||||
|
.then(function() {
|
||||||
|
reject();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Promise.all([thenable])
|
||||||
|
.then(function() {
|
||||||
|
$DONE('The promise should not be fulfilled.');
|
||||||
|
}, function(x) {
|
||||||
|
$DONE();
|
||||||
|
});
|
53
test/built-ins/Promise/all/reject-ignored-deferred.js
Normal file
53
test/built-ins/Promise/all/reject-ignored-deferred.js
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
description: >
|
||||||
|
Resolved promises ignore rejections through deferred invocation of the
|
||||||
|
provided resolving function
|
||||||
|
es6id: 25.4.4.1
|
||||||
|
info: >
|
||||||
|
[...]
|
||||||
|
6. Let promiseCapability be NewPromiseCapability(C).
|
||||||
|
[...]
|
||||||
|
11. Let result be PerformPromiseAll(iteratorRecord, promiseCapability, C).
|
||||||
|
[...]
|
||||||
|
|
||||||
|
25.4.4.1.1 Runtime Semantics: PerformPromiseAll
|
||||||
|
[...]
|
||||||
|
6. Repeat
|
||||||
|
[...]
|
||||||
|
r. Let result be Invoke(nextPromise, "then", resolveElement,
|
||||||
|
promiseCapability.[[Reject]]»).
|
||||||
|
|
||||||
|
25.4.1.3.1 Promise Reject Functions
|
||||||
|
[...]
|
||||||
|
2. Let promise be the value of F's [[Promise]] internal slot.
|
||||||
|
3. Let alreadyResolved be the value of F's [[AlreadyResolved]] internal
|
||||||
|
slot.
|
||||||
|
4. If alreadyResolved.[[value]] is true, return undefined.
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var fulfiller = {
|
||||||
|
then: function(resolve) {
|
||||||
|
new Promise(function(resolve) { resolve(); })
|
||||||
|
.then(function() {
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var rejector = {
|
||||||
|
then: function(resolve, reject) {
|
||||||
|
new Promise(function(resolve) { resolve(); })
|
||||||
|
.then(function() {
|
||||||
|
resolve();
|
||||||
|
reject();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Promise.all([fulfiller, rejector])
|
||||||
|
.then(function() {
|
||||||
|
$DONE();
|
||||||
|
}, function() {
|
||||||
|
$DONE('The promise should not be rejected.');
|
||||||
|
});
|
47
test/built-ins/Promise/all/reject-ignored-immed.js
Normal file
47
test/built-ins/Promise/all/reject-ignored-immed.js
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
description: >
|
||||||
|
Resolved promises ignore rejections through immediate invocation of the
|
||||||
|
provided resolving function
|
||||||
|
es6id: 25.4.4.1
|
||||||
|
info: >
|
||||||
|
[...]
|
||||||
|
6. Let promiseCapability be NewPromiseCapability(C).
|
||||||
|
[...]
|
||||||
|
11. Let result be PerformPromiseAll(iteratorRecord, promiseCapability, C).
|
||||||
|
[...]
|
||||||
|
|
||||||
|
25.4.4.1.1 Runtime Semantics: PerformPromiseAll
|
||||||
|
[...]
|
||||||
|
6. Repeat
|
||||||
|
[...]
|
||||||
|
r. Let result be Invoke(nextPromise, "then", resolveElement,
|
||||||
|
promiseCapability.[[Reject]]»).
|
||||||
|
|
||||||
|
25.4.1.3.1 Promise Reject Functions
|
||||||
|
[...]
|
||||||
|
2. Let promise be the value of F's [[Promise]] internal slot.
|
||||||
|
3. Let alreadyResolved be the value of F's [[AlreadyResolved]] internal
|
||||||
|
slot.
|
||||||
|
4. If alreadyResolved.[[value]] is true, return undefined.
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var fulfiller = {
|
||||||
|
then: function(resolve) {
|
||||||
|
resolve();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var lateRejector = {
|
||||||
|
then: function(resolve, reject) {
|
||||||
|
resolve();
|
||||||
|
reject();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Promise.all([fulfiller, lateRejector])
|
||||||
|
.then(function() {
|
||||||
|
$DONE();
|
||||||
|
}, function() {
|
||||||
|
$DONE('The promise should not be rejected.');
|
||||||
|
});
|
36
test/built-ins/Promise/all/reject-immed.js
Normal file
36
test/built-ins/Promise/all/reject-immed.js
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
description: Rejecting through immediate invocation of the provided resolving function
|
||||||
|
es6id: 25.4.4.1
|
||||||
|
info: >
|
||||||
|
[...]
|
||||||
|
6. Let promiseCapability be NewPromiseCapability(C).
|
||||||
|
[...]
|
||||||
|
11. Let result be PerformPromiseAll(iteratorRecord, promiseCapability, C).
|
||||||
|
[...]
|
||||||
|
|
||||||
|
25.4.4.1.1 Runtime Semantics: PerformPromiseAll
|
||||||
|
[...]
|
||||||
|
6. Repeat
|
||||||
|
[...]
|
||||||
|
r. Let result be Invoke(nextPromise, "then", resolveElement,
|
||||||
|
promiseCapability.[[Reject]]»).
|
||||||
|
|
||||||
|
25.4.1.3.1 Promise Reject Functions
|
||||||
|
[...]
|
||||||
|
6. Return RejectPromise(promise, reason).
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var thenable = {
|
||||||
|
then: function(_, reject) {
|
||||||
|
reject();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Promise.all([thenable])
|
||||||
|
.then(function() {
|
||||||
|
$DONE('The promise should not be fulfilled.');
|
||||||
|
}, function(x) {
|
||||||
|
$DONE();
|
||||||
|
});
|
43
test/built-ins/Promise/prototype/then/reject-pending-fulfilled.js
vendored
Normal file
43
test/built-ins/Promise/prototype/then/reject-pending-fulfilled.js
vendored
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
description: Rejecting from a pending promise that is later fulfilled
|
||||||
|
es6id: 25.4.5.3
|
||||||
|
info: >
|
||||||
|
[...]
|
||||||
|
7. Return PerformPromiseThen(promise, onFulfilled, onRejected,
|
||||||
|
resultCapability).
|
||||||
|
|
||||||
|
25.4.5.3.1 PerformPromiseThen
|
||||||
|
[...]
|
||||||
|
7. If the value of promise's [[PromiseState]] internal slot is "pending",
|
||||||
|
a. Append fulfillReaction as the last element of the List that is the
|
||||||
|
value of promise's [[PromiseFulfillReactions]] internal slot.
|
||||||
|
[...]
|
||||||
|
|
||||||
|
25.4.1.3.1 Promise Reject Functions
|
||||||
|
[...]
|
||||||
|
6. Return RejectPromise(promise, reason).
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var resolve;
|
||||||
|
var thenable = new Promise(function(_resolve) { resolve = _resolve; });
|
||||||
|
var p1 = new Promise(function(resolve) { resolve(); });
|
||||||
|
var p2;
|
||||||
|
|
||||||
|
p2 = p1.then(function() {
|
||||||
|
throw thenable;
|
||||||
|
});
|
||||||
|
|
||||||
|
p2.then(function() {
|
||||||
|
$DONE('The promise should not be fulfilled.');
|
||||||
|
}, function(x) {
|
||||||
|
if (x !== thenable) {
|
||||||
|
$DONE('The promise should be rejected with the resolution value of the provided promise.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$DONE();
|
||||||
|
});
|
||||||
|
|
||||||
|
resolve();
|
44
test/built-ins/Promise/prototype/then/reject-pending-rejected.js
vendored
Normal file
44
test/built-ins/Promise/prototype/then/reject-pending-rejected.js
vendored
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
description: Rejecting from a pending promise that is later rejected
|
||||||
|
es6id: 25.4.5.3
|
||||||
|
info: >
|
||||||
|
[...]
|
||||||
|
7. Return PerformPromiseThen(promise, onFulfilled, onRejected,
|
||||||
|
resultCapability).
|
||||||
|
|
||||||
|
25.4.5.3.1 PerformPromiseThen
|
||||||
|
[...]
|
||||||
|
7. If the value of promise's [[PromiseState]] internal slot is "pending",
|
||||||
|
[...]
|
||||||
|
b. Append rejectReaction as the last element of the List that is the
|
||||||
|
value of promise's [[PromiseRejectReactions]] internal slot.
|
||||||
|
[...]
|
||||||
|
|
||||||
|
25.4.1.3.1 Promise Reject Functions
|
||||||
|
[...]
|
||||||
|
6. Return RejectPromise(promise, reason).
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var reject;
|
||||||
|
var thenable = new Promise(function(resolve) { resolve(); });
|
||||||
|
var p1 = new Promise(function(_, _reject) { reject = _reject; });
|
||||||
|
var p2;
|
||||||
|
|
||||||
|
p2 = p1.then(function() {}, function() {
|
||||||
|
throw thenable;
|
||||||
|
});
|
||||||
|
|
||||||
|
p2.then(function() {
|
||||||
|
$DONE('The promise should not be fulfilled.');
|
||||||
|
}, function(x) {
|
||||||
|
if (x !== thenable) {
|
||||||
|
$DONE('The promise should be rejected with the resolution value of the provided promise.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$DONE();
|
||||||
|
});
|
||||||
|
|
||||||
|
reject();
|
48
test/built-ins/Promise/prototype/then/reject-settled-fulfilled.js
vendored
Normal file
48
test/built-ins/Promise/prototype/then/reject-settled-fulfilled.js
vendored
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
description: Rejecting from a fulfilled promise
|
||||||
|
es6id: 25.4.5.3
|
||||||
|
info: >
|
||||||
|
[...]
|
||||||
|
7. Return PerformPromiseThen(promise, onFulfilled, onRejected,
|
||||||
|
resultCapability).
|
||||||
|
|
||||||
|
25.4.5.3.1 PerformPromiseThen
|
||||||
|
[...]
|
||||||
|
8. Else if the value of promise's [[PromiseState]] internal slot is
|
||||||
|
"fulfilled",
|
||||||
|
a. Let value be the value of promise's [[PromiseResult]] internal slot.
|
||||||
|
b. EnqueueJob("PromiseJobs", PromiseReactionJob, «fulfillReaction,
|
||||||
|
value»).
|
||||||
|
|
||||||
|
25.4.2.1 PromiseReactionJob
|
||||||
|
[...]
|
||||||
|
7. If handlerResult is an abrupt completion, then
|
||||||
|
a. Let status be Call(promiseCapability.[[Reject]], undefined,
|
||||||
|
«handlerResult.[[value]]»).
|
||||||
|
[...]
|
||||||
|
|
||||||
|
25.4.1.3.1 Promise Reject Functions
|
||||||
|
[...]
|
||||||
|
6. Return RejectPromise(promise, reason).
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var thenable = new Promise(function(resolve) { resolve(); });
|
||||||
|
var p1 = new Promise(function(resolve) { resolve(); });
|
||||||
|
var p2;
|
||||||
|
|
||||||
|
p2 = p1.then(function() {
|
||||||
|
throw thenable;
|
||||||
|
});
|
||||||
|
|
||||||
|
p2.then(function() {
|
||||||
|
$DONE('The promise should not be fulfilled.');
|
||||||
|
}, function(x) {
|
||||||
|
if (x !== thenable) {
|
||||||
|
$DONE('The promise should be rejected with the resolution value of the provided promise.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$DONE();
|
||||||
|
});
|
48
test/built-ins/Promise/prototype/then/reject-settled-rejected.js
vendored
Normal file
48
test/built-ins/Promise/prototype/then/reject-settled-rejected.js
vendored
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
description: Rejecting from a rejected promise
|
||||||
|
es6id: 25.4.5.3
|
||||||
|
info: >
|
||||||
|
[...]
|
||||||
|
7. Return PerformPromiseThen(promise, onFulfilled, onRejected,
|
||||||
|
resultCapability).
|
||||||
|
|
||||||
|
25.4.5.3.1 PerformPromiseThen
|
||||||
|
[...]
|
||||||
|
9. Else if the value of promise's [[PromiseState]] internal slot is
|
||||||
|
"rejected",
|
||||||
|
a. Let reason be the value of promise's [[PromiseResult]] internal slot.
|
||||||
|
b. Perform EnqueueJob("PromiseJobs", PromiseReactionJob,
|
||||||
|
«rejectReaction, reason»).
|
||||||
|
|
||||||
|
25.4.2.1 PromiseReactionJob
|
||||||
|
[...]
|
||||||
|
7. If handlerResult is an abrupt completion, then
|
||||||
|
a. Let status be Call(promiseCapability.[[Reject]], undefined,
|
||||||
|
«handlerResult.[[value]]»).
|
||||||
|
[...]
|
||||||
|
|
||||||
|
25.4.1.3.1 Promise Reject Functions
|
||||||
|
[...]
|
||||||
|
6. Return RejectPromise(promise, reason).
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var thenable = new Promise(function(resolve) { resolve(); });
|
||||||
|
var p1 = new Promise(function(_, reject) { reject(); });
|
||||||
|
var p2;
|
||||||
|
|
||||||
|
p2 = p1.then(function() {}, function() {
|
||||||
|
throw thenable;
|
||||||
|
});
|
||||||
|
|
||||||
|
p2.then(function() {
|
||||||
|
$DONE('The promise should not be fulfilled.');
|
||||||
|
}, function(x) {
|
||||||
|
if (x !== thenable) {
|
||||||
|
$DONE('The promise should be rejected with the resolution value of the provided promise.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$DONE();
|
||||||
|
});
|
38
test/built-ins/Promise/race/reject-deferred.js
Normal file
38
test/built-ins/Promise/race/reject-deferred.js
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
description: Rejecting through deferred invocation of the provided resolving function
|
||||||
|
es6id: 25.4.4.3
|
||||||
|
info: >
|
||||||
|
[...]
|
||||||
|
6. Let promiseCapability be NewPromiseCapability(C).
|
||||||
|
[...]
|
||||||
|
11. Let result be PerformPromiseRace(iteratorRecord, promiseCapability, C).
|
||||||
|
[...]
|
||||||
|
|
||||||
|
25.4.4.3.1 Runtime Semantics: PerformPromiseRace
|
||||||
|
1. Repeat
|
||||||
|
[...]
|
||||||
|
j. Let result be Invoke(nextPromise, "then",
|
||||||
|
«promiseCapability.[[Resolve]], promiseCapability.[[Reject]]»).
|
||||||
|
|
||||||
|
25.4.1.3.1 Promise Reject Functions
|
||||||
|
[...]
|
||||||
|
6. Return RejectPromise(promise, reason).
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var thenable = {
|
||||||
|
then: function(_, reject) {
|
||||||
|
new Promise(function(resolve) { resolve(); })
|
||||||
|
.then(function() {
|
||||||
|
reject();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Promise.race([thenable])
|
||||||
|
.then(function() {
|
||||||
|
$DONE('The promise should not be fulfilled.');
|
||||||
|
}, function() {
|
||||||
|
$DONE();
|
||||||
|
});
|
51
test/built-ins/Promise/race/reject-ignored-deferred.js
Normal file
51
test/built-ins/Promise/race/reject-ignored-deferred.js
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
description: >
|
||||||
|
Resolved promises ignore rejections through deferred invocation of the
|
||||||
|
provided resolving function
|
||||||
|
es6id: 25.4.4.3
|
||||||
|
info: >
|
||||||
|
[...]
|
||||||
|
6. Let promiseCapability be NewPromiseCapability(C).
|
||||||
|
[...]
|
||||||
|
11. Let result be PerformPromiseRace(iteratorRecord, promiseCapability, C).
|
||||||
|
[...]
|
||||||
|
|
||||||
|
25.4.4.3.1 Runtime Semantics: PerformPromiseRace
|
||||||
|
1. Repeat
|
||||||
|
[...]
|
||||||
|
j. Let result be Invoke(nextPromise, "then",
|
||||||
|
«promiseCapability.[[Resolve]], promiseCapability.[[Reject]]»).
|
||||||
|
|
||||||
|
25.4.1.3.1 Promise Reject Functions
|
||||||
|
[...]
|
||||||
|
2. Let promise be the value of F's [[Promise]] internal slot.
|
||||||
|
3. Let alreadyResolved be the value of F's [[AlreadyResolved]] internal
|
||||||
|
slot.
|
||||||
|
4. If alreadyResolved.[[value]] is true, return undefined.
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var fulfiller = {
|
||||||
|
then: function(resolve) {
|
||||||
|
new Promise(function(resolve) { resolve(); })
|
||||||
|
.then(function() {
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var rejector = {
|
||||||
|
then: function(_, reject) {
|
||||||
|
new Promise(function(resolve) { resolve(); })
|
||||||
|
.then(function() {
|
||||||
|
reject();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Promise.race([fulfiller, rejector])
|
||||||
|
.then(function() {
|
||||||
|
$DONE();
|
||||||
|
}, function() {
|
||||||
|
$DONE('The promise should not be rejected.');
|
||||||
|
});
|
45
test/built-ins/Promise/race/reject-ignored-immed.js
Normal file
45
test/built-ins/Promise/race/reject-ignored-immed.js
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
description: >
|
||||||
|
Resolved promises ignore rejections through immediate invocation of the
|
||||||
|
provided resolving function
|
||||||
|
es6id: 25.4.4.3
|
||||||
|
info: >
|
||||||
|
[...]
|
||||||
|
6. Let promiseCapability be NewPromiseCapability(C).
|
||||||
|
[...]
|
||||||
|
11. Let result be PerformPromiseRace(iteratorRecord, promiseCapability, C).
|
||||||
|
[...]
|
||||||
|
|
||||||
|
25.4.4.3.1 Runtime Semantics: PerformPromiseRace
|
||||||
|
1. Repeat
|
||||||
|
[...]
|
||||||
|
j. Let result be Invoke(nextPromise, "then",
|
||||||
|
«promiseCapability.[[Resolve]], promiseCapability.[[Reject]]»).
|
||||||
|
|
||||||
|
25.4.1.3.1 Promise Reject Functions
|
||||||
|
[...]
|
||||||
|
2. Let promise be the value of F's [[Promise]] internal slot.
|
||||||
|
3. Let alreadyResolved be the value of F's [[AlreadyResolved]] internal
|
||||||
|
slot.
|
||||||
|
4. If alreadyResolved.[[value]] is true, return undefined.
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var fulfiller = {
|
||||||
|
then: function(resolve) {
|
||||||
|
resolve();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var rejector = {
|
||||||
|
then: function(_, reject) {
|
||||||
|
reject();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Promise.race([fulfiller, rejector])
|
||||||
|
.then(function() {
|
||||||
|
$DONE();
|
||||||
|
}, function() {
|
||||||
|
$DONE('The promise should not be rejected.');
|
||||||
|
});
|
35
test/built-ins/Promise/race/reject-immed.js
Normal file
35
test/built-ins/Promise/race/reject-immed.js
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
description: Rejecting through immediate invocation of the provided resolving function
|
||||||
|
es6id: 25.4.4.3
|
||||||
|
info: >
|
||||||
|
[...]
|
||||||
|
6. Let promiseCapability be NewPromiseCapability(C).
|
||||||
|
[...]
|
||||||
|
11. Let result be PerformPromiseRace(iteratorRecord, promiseCapability, C).
|
||||||
|
[...]
|
||||||
|
|
||||||
|
25.4.4.3.1 Runtime Semantics: PerformPromiseRace
|
||||||
|
1. Repeat
|
||||||
|
[...]
|
||||||
|
j. Let result be Invoke(nextPromise, "then",
|
||||||
|
«promiseCapability.[[Resolve]], promiseCapability.[[Reject]]»).
|
||||||
|
|
||||||
|
25.4.1.3.1 Promise Reject Functions
|
||||||
|
[...]
|
||||||
|
6. Return RejectPromise(promise, reason).
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var thenable = {
|
||||||
|
then: function(_, reject) {
|
||||||
|
reject();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Promise.race([thenable])
|
||||||
|
.then(function() {
|
||||||
|
$DONE('The promise should not be fulfilled.');
|
||||||
|
}, function() {
|
||||||
|
$DONE();
|
||||||
|
});
|
33
test/built-ins/Promise/reject-ignored-via-abrupt.js
Normal file
33
test/built-ins/Promise/reject-ignored-via-abrupt.js
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
description: Resolved promises ignore rejections through an abrupt completion
|
||||||
|
es6id: 25.4.3.1
|
||||||
|
info: >
|
||||||
|
[...]
|
||||||
|
9. Let completion be Call(executor, undefined,
|
||||||
|
«resolvingFunctions.[[Resolve]], resolvingFunctions.[[Reject]]»).
|
||||||
|
10. If completion is an abrupt completion, then
|
||||||
|
a. Let status be Call(resolvingFunctions.[[Reject]], undefined,
|
||||||
|
«completion.[[value]]»).
|
||||||
|
b. ReturnIfAbrupt(status).
|
||||||
|
11. Return promise.
|
||||||
|
|
||||||
|
25.4.1.3.1 Promise Reject Functions
|
||||||
|
[...]
|
||||||
|
3. Let alreadyResolved be the value of F's [[AlreadyResolved]] internal
|
||||||
|
slot.
|
||||||
|
4. If alreadyResolved.[[value]] is true, return undefined.
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var thenable = new Promise(function() {});
|
||||||
|
var p = new Promise(function(resolve) {
|
||||||
|
resolve();
|
||||||
|
throw thenable;
|
||||||
|
});
|
||||||
|
|
||||||
|
p.then(function() {
|
||||||
|
$DONE();
|
||||||
|
}, function() {
|
||||||
|
$DONE('The promise should not be rejected.');
|
||||||
|
});
|
37
test/built-ins/Promise/reject-ignored-via-fn-deferred.js
Normal file
37
test/built-ins/Promise/reject-ignored-via-fn-deferred.js
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
description: >
|
||||||
|
Resolved promises ignore rejections through deferred invocation of the
|
||||||
|
provided resolving function
|
||||||
|
es6id: 25.4.3.1
|
||||||
|
info: >
|
||||||
|
[...]
|
||||||
|
9. Let completion be Call(executor, undefined,
|
||||||
|
«resolvingFunctions.[[Resolve]], resolvingFunctions.[[Reject]]»).
|
||||||
|
10. If completion is an abrupt completion, then
|
||||||
|
[...]
|
||||||
|
11. Return promise.
|
||||||
|
|
||||||
|
25.4.1.3.1 Promise Reject Functions
|
||||||
|
[...]
|
||||||
|
3. Let alreadyResolved be the value of F's [[AlreadyResolved]] internal
|
||||||
|
slot.
|
||||||
|
4. If alreadyResolved.[[value]] is true, return undefined.
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var thenable = new Promise(function() {});
|
||||||
|
var resolve, reject;
|
||||||
|
var p = new Promise(function(_resolve, _reject) {
|
||||||
|
resolve = _resolve;
|
||||||
|
reject = _reject;
|
||||||
|
});
|
||||||
|
|
||||||
|
p.then(function() {
|
||||||
|
$DONE();
|
||||||
|
}, function() {
|
||||||
|
$DONE('The promise should not be rejected.');
|
||||||
|
});
|
||||||
|
|
||||||
|
resolve();
|
||||||
|
reject(thenable);
|
33
test/built-ins/Promise/reject-ignored-via-fn-immed.js
Normal file
33
test/built-ins/Promise/reject-ignored-via-fn-immed.js
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
description: >
|
||||||
|
Resolved promises ignore rejections through immediate invocation of the
|
||||||
|
provided resolving function
|
||||||
|
es6id: 25.4.3.1
|
||||||
|
info: >
|
||||||
|
[...]
|
||||||
|
9. Let completion be Call(executor, undefined,
|
||||||
|
«resolvingFunctions.[[Resolve]], resolvingFunctions.[[Reject]]»).
|
||||||
|
10. If completion is an abrupt completion, then
|
||||||
|
[...]
|
||||||
|
11. Return promise.
|
||||||
|
|
||||||
|
25.4.1.3.1 Promise Reject Functions
|
||||||
|
[...]
|
||||||
|
3. Let alreadyResolved be the value of F's [[AlreadyResolved]] internal
|
||||||
|
slot.
|
||||||
|
4. If alreadyResolved.[[value]] is true, return undefined.
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var thenable = new Promise(function() {});
|
||||||
|
var p = new Promise(function(resolve, reject) {
|
||||||
|
resolve();
|
||||||
|
reject(thenable);
|
||||||
|
});
|
||||||
|
|
||||||
|
p.then(function() {
|
||||||
|
$DONE();
|
||||||
|
}, function() {
|
||||||
|
$DONE('The promise should not be rejected.');
|
||||||
|
});
|
35
test/built-ins/Promise/reject-via-abrupt.js
Normal file
35
test/built-ins/Promise/reject-via-abrupt.js
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
description: Rejecting through an abrupt completion
|
||||||
|
es6id: 25.4.3.1
|
||||||
|
info: >
|
||||||
|
[...]
|
||||||
|
9. Let completion be Call(executor, undefined,
|
||||||
|
«resolvingFunctions.[[Resolve]], resolvingFunctions.[[Reject]]»).
|
||||||
|
10. If completion is an abrupt completion, then
|
||||||
|
a. Let status be Call(resolvingFunctions.[[Reject]], undefined,
|
||||||
|
«completion.[[value]]»).
|
||||||
|
b. ReturnIfAbrupt(status).
|
||||||
|
11. Return promise.
|
||||||
|
|
||||||
|
25.4.1.3.1 Promise Reject Functions
|
||||||
|
[...]
|
||||||
|
6. Return RejectPromise(promise, reason).
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var thenable = new Promise(function() {});
|
||||||
|
var p = new Promise(function() {
|
||||||
|
throw thenable;
|
||||||
|
});
|
||||||
|
|
||||||
|
p.then(function() {
|
||||||
|
$DONE('The promise should not be fulfilled.');
|
||||||
|
}, function(x) {
|
||||||
|
if (x !== thenable) {
|
||||||
|
$DONE('The promise should be rejected with the resolution value.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$DONE();
|
||||||
|
});
|
36
test/built-ins/Promise/reject-via-fn-deferred.js
Normal file
36
test/built-ins/Promise/reject-via-fn-deferred.js
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
description: Rejecting through deferred invocation of the provided resolving function
|
||||||
|
es6id: 25.4.3.1
|
||||||
|
info: >
|
||||||
|
[...]
|
||||||
|
9. Let completion be Call(executor, undefined,
|
||||||
|
«resolvingFunctions.[[Resolve]], resolvingFunctions.[[Reject]]»).
|
||||||
|
10. If completion is an abrupt completion, then
|
||||||
|
[...]
|
||||||
|
11. Return promise.
|
||||||
|
|
||||||
|
25.4.1.3.1 Promise Reject Functions
|
||||||
|
[...]
|
||||||
|
6. Return RejectPromise(promise, reason).
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var thenable = new Promise(function() {});
|
||||||
|
var reject;
|
||||||
|
var p = new Promise(function(_, _reject) {
|
||||||
|
reject = _reject;
|
||||||
|
});
|
||||||
|
|
||||||
|
p.then(function() {
|
||||||
|
$DONE('The promise should not be fulfilled.');
|
||||||
|
}, function(x) {
|
||||||
|
if (x !== thenable) {
|
||||||
|
$DONE('The promise should be rejected with the resolution value.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$DONE();
|
||||||
|
});
|
||||||
|
|
||||||
|
reject(thenable);
|
33
test/built-ins/Promise/reject-via-fn-immed.js
Normal file
33
test/built-ins/Promise/reject-via-fn-immed.js
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
description: Rejecting through immediate invocation of the provided resolving function
|
||||||
|
es6id: 25.4.3.1
|
||||||
|
info: >
|
||||||
|
[...]
|
||||||
|
9. Let completion be Call(executor, undefined,
|
||||||
|
«resolvingFunctions.[[Resolve]], resolvingFunctions.[[Reject]]»).
|
||||||
|
10. If completion is an abrupt completion, then
|
||||||
|
[...]
|
||||||
|
11. Return promise.
|
||||||
|
|
||||||
|
25.4.1.3.1 Promise Reject Functions
|
||||||
|
[...]
|
||||||
|
6. Return RejectPromise(promise, reason).
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var thenable = new Promise(function() {});
|
||||||
|
var p = new Promise(function(_, reject) {
|
||||||
|
reject(thenable);
|
||||||
|
});
|
||||||
|
|
||||||
|
p.then(function() {
|
||||||
|
$DONE('The promise should not be fulfilled.');
|
||||||
|
}, function(x) {
|
||||||
|
if (x !== thenable) {
|
||||||
|
$DONE('The promise should be rejected with the resolution value.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$DONE();
|
||||||
|
});
|
@ -3,8 +3,14 @@
|
|||||||
|
|
||||||
/*---
|
/*---
|
||||||
info: >
|
info: >
|
||||||
Promise.reject
|
[...]
|
||||||
es6id: S25.4.4.4_A2.1_T1
|
5. Let rejectResult be Call(promiseCapability.[[Reject]], undefined, «r»).
|
||||||
|
[...]
|
||||||
|
|
||||||
|
25.4.1.3.1 Promise Reject Functions
|
||||||
|
[...]
|
||||||
|
6. Return RejectPromise(promise, reason).
|
||||||
|
es6id: 25.4.4.4
|
||||||
author: Sam Mikes
|
author: Sam Mikes
|
||||||
description: Promise.reject creates a new settled promise
|
description: Promise.reject creates a new settled promise
|
||||||
---*/
|
---*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user