mirror of https://github.com/tc39/test262.git
Limit semantics under test
Because these tests concern the behavior of the PromiseReactionJob abstract operation itself, they should avoid assumptions about the correct implementation of that operation. Specifically: they should not rely on the behavior of abupt completions returned from "reaction handler" functions. Re-implement tests to express control flow expectations using the `$DONE` function only.
This commit is contained in:
parent
5a8d1fdf77
commit
5f2ba2522f
|
@ -16,9 +16,16 @@ var expectedThis = fnGlobalObject(),
|
|||
|
||||
var p = Promise.resolve(obj).then(function(arg) {
|
||||
if (this !== expectedThis) {
|
||||
$ERROR("'this' must be global object, got " + this);
|
||||
$DONE("'this' must be global object, got " + this);
|
||||
return;
|
||||
}
|
||||
|
||||
if (arg !== obj) {
|
||||
$ERROR("Expected promise to be fulfilled by obj, actually " + arg);
|
||||
$DONE("Expected promise to be fulfilled by obj, actually " + arg);
|
||||
return;
|
||||
}
|
||||
}).then($DONE, $DONE);
|
||||
|
||||
$DONE();
|
||||
}, function() {
|
||||
$DONE('The promise should not be rejected.');
|
||||
});
|
||||
|
|
|
@ -15,9 +15,16 @@ var expectedThis = undefined,
|
|||
|
||||
var p = Promise.resolve(obj).then(function(arg) {
|
||||
if (this !== expectedThis) {
|
||||
$ERROR("'this' must be undefined, got " + this);
|
||||
$DONE("'this' must be undefined, got " + this);
|
||||
return;
|
||||
}
|
||||
|
||||
if (arg !== obj) {
|
||||
$ERROR("Expected promise to be fulfilled by obj, actually " + arg);
|
||||
$DONE("Expected promise to be fulfilled by obj, actually " + arg);
|
||||
return;
|
||||
}
|
||||
}).then($DONE, $DONE);
|
||||
|
||||
$DONE();
|
||||
}, function() {
|
||||
$DONE('The promise should not be rejected.');
|
||||
});
|
||||
|
|
|
@ -14,6 +14,10 @@ var obj = {};
|
|||
var p = Promise.resolve(obj).then(/*Identity, Thrower*/)
|
||||
.then(function (arg) {
|
||||
if (arg !== obj) {
|
||||
$ERROR("Expected promise to be fulfilled with obj, actually " + arg);
|
||||
$DONE("Expected promise to be fulfilled with obj, actually " + arg);
|
||||
return;
|
||||
}
|
||||
}).then($DONE, $DONE);
|
||||
$DONE();
|
||||
}, function() {
|
||||
$DONE('The promise should not be rejected.');
|
||||
});
|
||||
|
|
|
@ -17,13 +17,17 @@ var expectedThis = fnGlobalObject(),
|
|||
obj = {};
|
||||
|
||||
var p = Promise.reject(obj).then(function () {
|
||||
$ERROR("Unexpected fulfillment; expected rejection.");
|
||||
$DONE("Unexpected fulfillment; expected rejection.");
|
||||
}, function(arg) {
|
||||
if (this !== expectedThis) {
|
||||
$ERROR("'this' must be global object, got " + this);
|
||||
$DONE("'this' must be global object, got " + this);
|
||||
return;
|
||||
}
|
||||
|
||||
if (arg !== obj) {
|
||||
$ERROR("Expected promise to be rejected with obj, actually " + arg);
|
||||
$DONE("Expected promise to be rejected with obj, actually " + arg);
|
||||
return;
|
||||
}
|
||||
}).then($DONE, $DONE);
|
||||
|
||||
$DONE();
|
||||
});
|
||||
|
|
|
@ -16,13 +16,17 @@ var expectedThis = undefined,
|
|||
obj = {};
|
||||
|
||||
var p = Promise.reject(obj).then(function () {
|
||||
$ERROR("Unexpected fulfillment; expected rejection.");
|
||||
$DONE("Unexpected fulfillment; expected rejection.");
|
||||
}, function(arg) {
|
||||
if (this !== expectedThis) {
|
||||
$ERROR("'this' must be undefined, got " + this);
|
||||
$DONE("'this' must be undefined, got " + this);
|
||||
return;
|
||||
}
|
||||
|
||||
if (arg !== obj) {
|
||||
$ERROR("Expected promise to be rejected with obj, actually " + arg);
|
||||
$DONE("Expected promise to be rejected with obj, actually " + arg);
|
||||
return;
|
||||
}
|
||||
}).then($DONE, $DONE);
|
||||
|
||||
$DONE();
|
||||
});
|
||||
|
|
|
@ -13,9 +13,11 @@ var obj = {};
|
|||
|
||||
var p = Promise.reject(obj).then(/*Identity, Thrower*/)
|
||||
.then(function () {
|
||||
$ERROR("Unexpected fulfillment - promise should reject.");
|
||||
$DONE("Unexpected fulfillment - promise should reject.");
|
||||
}, function (arg) {
|
||||
if (arg !== obj) {
|
||||
$ERROR("Expected reject reason to be obj, actually " + arg);
|
||||
$DONE("Expected reject reason to be obj, actually " + arg);
|
||||
return;
|
||||
}
|
||||
}).then($DONE, $DONE);
|
||||
$DONE();
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue