diff --git a/test/built-ins/Promise/all/reject-deferred.js b/test/built-ins/Promise/all/reject-deferred.js new file mode 100644 index 0000000000000000000000000000000000000000..6b7d43a1ea0ade6fa2e5e9e1d2a6ff3a1dd4c126 --- /dev/null +++ b/test/built-ins/Promise/all/reject-deferred.js @@ -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(); + }); diff --git a/test/built-ins/Promise/all/reject-ignored-deferred.js b/test/built-ins/Promise/all/reject-ignored-deferred.js new file mode 100644 index 0000000000000000000000000000000000000000..874e1d40f4c46a0efa433b7e718a6bd88500c8fe --- /dev/null +++ b/test/built-ins/Promise/all/reject-ignored-deferred.js @@ -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.'); + }); diff --git a/test/built-ins/Promise/all/reject-ignored-immed.js b/test/built-ins/Promise/all/reject-ignored-immed.js new file mode 100644 index 0000000000000000000000000000000000000000..6ef29d1c6bff0b17acb55e0a614d7bfa228d215f --- /dev/null +++ b/test/built-ins/Promise/all/reject-ignored-immed.js @@ -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.'); + }); diff --git a/test/built-ins/Promise/all/reject-immed.js b/test/built-ins/Promise/all/reject-immed.js new file mode 100644 index 0000000000000000000000000000000000000000..ce7ff4c4908cb52e76d852f555078dacfade0729 --- /dev/null +++ b/test/built-ins/Promise/all/reject-immed.js @@ -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(); + }); diff --git a/test/built-ins/Promise/prototype/then/reject-pending-fulfilled.js b/test/built-ins/Promise/prototype/then/reject-pending-fulfilled.js new file mode 100644 index 0000000000000000000000000000000000000000..f89ea8a8a841457650f86c1f9e215ebe85bc7b31 --- /dev/null +++ b/test/built-ins/Promise/prototype/then/reject-pending-fulfilled.js @@ -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(); diff --git a/test/built-ins/Promise/prototype/then/reject-pending-rejected.js b/test/built-ins/Promise/prototype/then/reject-pending-rejected.js new file mode 100644 index 0000000000000000000000000000000000000000..fee40661992c18a80134ad7a1b28baba97b0d62a --- /dev/null +++ b/test/built-ins/Promise/prototype/then/reject-pending-rejected.js @@ -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(); diff --git a/test/built-ins/Promise/prototype/then/reject-settled-fulfilled.js b/test/built-ins/Promise/prototype/then/reject-settled-fulfilled.js new file mode 100644 index 0000000000000000000000000000000000000000..bc638eaf5128a5e66614a296bf6150296f5c1280 --- /dev/null +++ b/test/built-ins/Promise/prototype/then/reject-settled-fulfilled.js @@ -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(); + }); diff --git a/test/built-ins/Promise/prototype/then/reject-settled-rejected.js b/test/built-ins/Promise/prototype/then/reject-settled-rejected.js new file mode 100644 index 0000000000000000000000000000000000000000..487b94444ca02c5fbd7c26f02813e71df1919a34 --- /dev/null +++ b/test/built-ins/Promise/prototype/then/reject-settled-rejected.js @@ -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(); + }); diff --git a/test/built-ins/Promise/race/reject-deferred.js b/test/built-ins/Promise/race/reject-deferred.js new file mode 100644 index 0000000000000000000000000000000000000000..e070cef6e2d2cbe11675cffb475eadac16b00dd0 --- /dev/null +++ b/test/built-ins/Promise/race/reject-deferred.js @@ -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(); + }); diff --git a/test/built-ins/Promise/race/reject-ignored-deferred.js b/test/built-ins/Promise/race/reject-ignored-deferred.js new file mode 100644 index 0000000000000000000000000000000000000000..bf63e7328be2a1f8ec9c29225f2415fdb6633424 --- /dev/null +++ b/test/built-ins/Promise/race/reject-ignored-deferred.js @@ -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.'); + }); diff --git a/test/built-ins/Promise/race/reject-ignored-immed.js b/test/built-ins/Promise/race/reject-ignored-immed.js new file mode 100644 index 0000000000000000000000000000000000000000..a22eac484f562c1c5698a32b4000633909db54fc --- /dev/null +++ b/test/built-ins/Promise/race/reject-ignored-immed.js @@ -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.'); + }); diff --git a/test/built-ins/Promise/race/reject-immed.js b/test/built-ins/Promise/race/reject-immed.js new file mode 100644 index 0000000000000000000000000000000000000000..4cfc9a925f4b0cda8bc47f1b5748bcf7a404ac94 --- /dev/null +++ b/test/built-ins/Promise/race/reject-immed.js @@ -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(); + }); diff --git a/test/built-ins/Promise/reject-ignored-via-abrupt.js b/test/built-ins/Promise/reject-ignored-via-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..f3cb6c7a778d1fe7ea8bca99c8ee4f68391bd44d --- /dev/null +++ b/test/built-ins/Promise/reject-ignored-via-abrupt.js @@ -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.'); + }); diff --git a/test/built-ins/Promise/reject-ignored-via-fn-deferred.js b/test/built-ins/Promise/reject-ignored-via-fn-deferred.js new file mode 100644 index 0000000000000000000000000000000000000000..10b0d81e03031b0c89d0d654ee1decf8e73c2d66 --- /dev/null +++ b/test/built-ins/Promise/reject-ignored-via-fn-deferred.js @@ -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); diff --git a/test/built-ins/Promise/reject-ignored-via-fn-immed.js b/test/built-ins/Promise/reject-ignored-via-fn-immed.js new file mode 100644 index 0000000000000000000000000000000000000000..bd856a342f06acc458d049250de75704c808a9a8 --- /dev/null +++ b/test/built-ins/Promise/reject-ignored-via-fn-immed.js @@ -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.'); + }); diff --git a/test/built-ins/Promise/reject-via-abrupt.js b/test/built-ins/Promise/reject-via-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..6e608bdc22b6c412e3e65b3c700ca2903bd43c66 --- /dev/null +++ b/test/built-ins/Promise/reject-via-abrupt.js @@ -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(); + }); diff --git a/test/built-ins/Promise/reject-via-fn-deferred.js b/test/built-ins/Promise/reject-via-fn-deferred.js new file mode 100644 index 0000000000000000000000000000000000000000..855d92b4100017102ad5165ca460d3a839c6152e --- /dev/null +++ b/test/built-ins/Promise/reject-via-fn-deferred.js @@ -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); diff --git a/test/built-ins/Promise/reject-via-fn-immed.js b/test/built-ins/Promise/reject-via-fn-immed.js new file mode 100644 index 0000000000000000000000000000000000000000..474db80d8b7bfd5628519cc4132b0560f2bd1b6d --- /dev/null +++ b/test/built-ins/Promise/reject-via-fn-immed.js @@ -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(); + }); diff --git a/test/built-ins/Promise/reject/S25.4.4.4_A2.1_T1.js b/test/built-ins/Promise/reject/S25.4.4.4_A2.1_T1.js index 1c721b3d722400546b2e43ab79b553de3ceda1f5..bc589ac13f992ba88ac95dee145da19064ad2fad 100644 --- a/test/built-ins/Promise/reject/S25.4.4.4_A2.1_T1.js +++ b/test/built-ins/Promise/reject/S25.4.4.4_A2.1_T1.js @@ -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 ---*/