diff options
author | Mike Pennisi <mike@mikepennisi.com> | 2015-12-30 17:26:08 -0500 |
---|---|---|
committer | Mike Pennisi <mike@mikepennisi.com> | 2016-01-07 13:24:01 -0500 |
commit | a5bf19486a6e5a58193580c088fb715baa57f90e (patch) | |
tree | 8022f7cc3fdceaf1057ec03e864cfb767f6881d6 /test/built-ins/Promise | |
parent | 8e069e918f519e60545710d130766df32dfae5b9 (diff) | |
download | qtdeclarative-testsuites-a5bf19486a6e5a58193580c088fb715baa57f90e.tar.gz |
Extend coverage for PerformPromiseThen
Diffstat (limited to 'test/built-ins/Promise')
-rw-r--r-- | test/built-ins/Promise/prototype/then/prfm-pending-fulfulled.js | 35 | ||||
-rw-r--r-- | test/built-ins/Promise/prototype/then/prfm-pending-rejected.js | 35 |
2 files changed, 70 insertions, 0 deletions
diff --git a/test/built-ins/Promise/prototype/then/prfm-pending-fulfulled.js b/test/built-ins/Promise/prototype/then/prfm-pending-fulfulled.js new file mode 100644 index 000000000..b0d63c056 --- /dev/null +++ b/test/built-ins/Promise/prototype/then/prfm-pending-fulfulled.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. +/*--- +es6id: 25.4.5.3 +description: PerformPromiseThen on a pending promise that is later fulfilled +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. + b. Append rejectReaction as the last element of the List that is the + value of promise's [[PromiseRejectReactions]] internal slot. + [...] +---*/ + +var value = {}; +var resolve; +var p = new Promise(function(_resolve) { resolve = _resolve; }); + +p.then(function(x) { + if (x !== value) { + $DONE('The `onFulfilled` handler should be invoked with the promise result.'); + return; + } + $DONE(); + }, function() { + $DONE('The `onRejected` handler should not be invoked.'); + }); + +resolve(value); diff --git a/test/built-ins/Promise/prototype/then/prfm-pending-rejected.js b/test/built-ins/Promise/prototype/then/prfm-pending-rejected.js new file mode 100644 index 000000000..23afce4b3 --- /dev/null +++ b/test/built-ins/Promise/prototype/then/prfm-pending-rejected.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. +/*--- +es6id: 25.4.5.3 +description: PerformPromiseThen on a pending promise that is later rejected +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. + b. Append rejectReaction as the last element of the List that is the + value of promise's [[PromiseRejectReactions]] internal slot. + [...] +---*/ + +var value = {}; +var reject; +var p = new Promise(function(_, _reject) { reject = _reject; }); + +p.then(function() { + $DONE('The `onFulfilled` handler should not be invoked.'); + }, function(x) { + if (x !== value) { + $DONE('The `onRejected` handler should be invoked with the promise result.'); + return; + } + $DONE(); + }); + +reject(value); |