mirror of https://github.com/tc39/test262.git
Add tests for Promise Reject Functions
This commit is contained in:
parent
a5bf19486a
commit
7fab70bb21
|
@ -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();
|
||||
});
|
|
@ -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.');
|
||||
});
|
|
@ -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.');
|
||||
});
|
|
@ -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();
|
||||
});
|
|
@ -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();
|
|
@ -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();
|
|
@ -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();
|
||||
});
|
|
@ -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();
|
||||
});
|
|
@ -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();
|
||||
});
|
|
@ -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.');
|
||||
});
|
|
@ -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.');
|
||||
});
|
|
@ -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();
|
||||
});
|
|
@ -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.');
|
||||
});
|
|
@ -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);
|
|
@ -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.');
|
||||
});
|
|
@ -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();
|
||||
});
|
|
@ -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);
|
|
@ -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: >
|
||||
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
|
||||
description: Promise.reject creates a new settled promise
|
||||
---*/
|
||||
|
|
Loading…
Reference in New Issue