mirror of https://github.com/tc39/test262.git
Extend tests for Promise resolve and reject fns
Assert expected return values in all cases.
This commit is contained in:
parent
1eaae52eb8
commit
023ab45cf0
|
@ -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');
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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.');
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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.');
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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.');
|
||||
|
|
Loading…
Reference in New Issue