Extend tests for Promise resolve and reject fns

Assert expected return values in all cases.
This commit is contained in:
Mike Pennisi 2016-06-24 13:04:21 -04:00
parent 1eaae52eb8
commit 023ab45cf0
15 changed files with 60 additions and 15 deletions

View File

@ -21,6 +21,7 @@ info: >
flags: [async]
---*/
var returnValue = null;
var thenable = new Promise(function() {});
var resolve, reject;
var p = new Promise(function(_resolve, _reject) {
@ -35,4 +36,6 @@ p.then(function() {
});
resolve();
reject(thenable);
returnValue = reject(thenable);
assert.sameValue(returnValue, undefined, '"reject" function return value');

View File

@ -21,12 +21,15 @@ info: >
flags: [async]
---*/
var returnValue = null;
var thenable = new Promise(function() {});
var p = new Promise(function(resolve, reject) {
resolve();
reject(thenable);
returnValue = reject(thenable);
});
assert.sameValue(returnValue, undefined, '"reject" function return value');
p.then(function() {
$DONE();
}, function() {

View File

@ -18,6 +18,7 @@ flags: [async]
---*/
var thenable = new Promise(function() {});
var returnValue = null;
var reject;
var p = new Promise(function(_, _reject) {
reject = _reject;
@ -34,4 +35,6 @@ p.then(function() {
$DONE();
});
reject(thenable);
returnValue = reject(thenable);
assert.sameValue(returnValue, undefined, '"reject" function return value');

View File

@ -18,10 +18,13 @@ flags: [async]
---*/
var thenable = new Promise(function() {});
var returnValue = null;
var p = new Promise(function(_, reject) {
reject(thenable);
returnValue = reject(thenable);
});
assert.sameValue(returnValue, undefined, '"reject" function return value');
p.then(function() {
$DONE('The promise should not be fulfilled.');
}, function(x) {

View File

@ -16,6 +16,7 @@ info: >
flags: [async]
---*/
var returnValue = null;
var resolve;
var promise = new Promise(function(_resolve) {
resolve = _resolve;
@ -32,4 +33,6 @@ promise.then(function(value) {
$DONE('The promise should not be rejected.');
});
resolve(45);
returnValue = resolve(45);
assert.sameValue(returnValue, undefined, '"resolve" return value');

View File

@ -15,10 +15,13 @@ info: >
flags: [async]
---*/
var returnValue = null;
var promise = new Promise(function(resolve) {
resolve(45);
returnValue = resolve(45);
});
assert.sameValue(returnValue, undefined, '"resolve" return value');
promise.then(function(value) {
if (value !== 45) {
$DONE('The promise should be fulfilled with the provided value.');

View File

@ -21,6 +21,7 @@ info: >
flags: [async]
---*/
var returnValue = null;
var nonThenable = { then: null };
var resolve;
var promise = new Promise(function(_resolve) {
@ -38,4 +39,6 @@ promise.then(function(value) {
$DONE('The promise should not be rejected.');
});
resolve(nonThenable);
returnValue = resolve(nonThenable);
assert.sameValue(returnValue, undefined, '"resolve" return value');

View File

@ -21,11 +21,14 @@ info: >
flags: [async]
---*/
var returnValue = null;
var nonThenable = { then: null };
var promise = new Promise(function(resolve) {
resolve(nonThenable);
returnValue = resolve(nonThenable);
});
assert.sameValue(returnValue, undefined, '"resolve" return value');
promise.then(function(value) {
if (value !== nonThenable) {
$DONE('The promise should be fulfilled with the provided value.');

View File

@ -17,6 +17,7 @@ info: >
flags: [async]
---*/
var returnValue = null;
var value = {};
var resolve;
var poisonedThen = Object.defineProperty({}, 'then', {
@ -39,4 +40,6 @@ promise.then(function() {
$DONE();
});
resolve(poisonedThen);
returnValue = resolve(poisonedThen);
assert.sameValue(returnValue, undefined, '"resolve" return value');

View File

@ -17,6 +17,7 @@ info: >
flags: [async]
---*/
var returnValue = null;
var value = {};
var poisonedThen = Object.defineProperty({}, 'then', {
get: function() {
@ -24,9 +25,11 @@ var poisonedThen = Object.defineProperty({}, 'then', {
}
});
var promise = new Promise(function(resolve) {
resolve(poisonedThen);
returnValue = resolve(poisonedThen);
});
assert.sameValue(returnValue, undefined, '"resolve" return value');
promise.then(function() {
$DONE('The promise should not be fulfilled.');
}, function(val) {

View File

@ -23,6 +23,7 @@ info: >
«promise, resolution, thenAction»)
---*/
var returnValue = null;
var value = {};
var resolve;
var thenable = new Promise(function(resolve) { resolve(); });
@ -45,4 +46,6 @@ promise.then(function(val) {
$DONE('The promise should not be rejected.');
});
resolve(thenable);
returnValue = resolve(thenable);
assert.sameValue(returnValue, undefined, '"resolve" return value');

View File

@ -23,6 +23,7 @@ info: >
«promise, resolution, thenAction»)
---*/
var returnValue = null;
var value = {};
var lateCallCount = 0;
var thenable = new Promise(function(resolve) { resolve(); });
@ -32,9 +33,11 @@ thenable.then = function(resolve) {
};
var promise = new Promise(function(resolve) {
resolve(thenable);
returnValue = resolve(thenable);
});
assert.sameValue(returnValue, undefined, '"resolve" return value');
thenable.then = function() {
lateCallCount += 1;
};

View File

@ -17,6 +17,7 @@ info: >
flags: [async]
---*/
var returnValue = null;
var resolve;
var promise = new Promise(function(_resolve) {
resolve = _resolve;
@ -38,4 +39,6 @@ promise.then(function() {
$DONE();
});
resolve(promise);
returnValue = resolve(promise);
assert.sameValue(returnValue, undefined, '"resolve" return value');

View File

@ -24,6 +24,7 @@ info: >
flags: [async]
---*/
var returnValue = null;
var value = {};
var resolve;
var thenable = new Promise(function(resolve) { resolve(value); });
@ -42,4 +43,6 @@ promise.then(function(val) {
$DONE('The promise should not be rejected.');
});
resolve(thenable);
returnValue = resolve(thenable);
assert.sameValue(returnValue, undefined, '"resolve" return value');

View File

@ -23,12 +23,15 @@ info: >
flags: [async]
---*/
var returnValue = null;
var value = {};
var thenable = new Promise(function(resolve) { resolve(value); });
var promise = new Promise(function(resolve) {
resolve(thenable);
returnValue = resolve(thenable);
});
assert.sameValue(returnValue, undefined, '"resolve" return value');
promise.then(function(val) {
if (val !== value) {
$DONE('The promise should be fulfilled with the provided value.');