Skip to content
Snippets Groups Projects
Commit 5f2ba252 authored by Mike Pennisi's avatar Mike Pennisi
Browse files

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.
parent 5a8d1fdf
No related branches found
No related tags found
No related merge requests found
...@@ -16,9 +16,16 @@ var expectedThis = fnGlobalObject(), ...@@ -16,9 +16,16 @@ var expectedThis = fnGlobalObject(),
var p = Promise.resolve(obj).then(function(arg) { var p = Promise.resolve(obj).then(function(arg) {
if (this !== expectedThis) { if (this !== expectedThis) {
$ERROR("'this' must be global object, got " + this); $DONE("'this' must be global object, got " + this);
return;
} }
if (arg !== obj) { 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, ...@@ -15,9 +15,16 @@ var expectedThis = undefined,
var p = Promise.resolve(obj).then(function(arg) { var p = Promise.resolve(obj).then(function(arg) {
if (this !== expectedThis) { if (this !== expectedThis) {
$ERROR("'this' must be undefined, got " + this); $DONE("'this' must be undefined, got " + this);
return;
} }
if (arg !== obj) { 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 = {}; ...@@ -14,6 +14,10 @@ var obj = {};
var p = Promise.resolve(obj).then(/*Identity, Thrower*/) var p = Promise.resolve(obj).then(/*Identity, Thrower*/)
.then(function (arg) { .then(function (arg) {
if (arg !== obj) { 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(), ...@@ -17,13 +17,17 @@ var expectedThis = fnGlobalObject(),
obj = {}; obj = {};
var p = Promise.reject(obj).then(function () { var p = Promise.reject(obj).then(function () {
$ERROR("Unexpected fulfillment; expected rejection."); $DONE("Unexpected fulfillment; expected rejection.");
}, function(arg) { }, function(arg) {
if (this !== expectedThis) { if (this !== expectedThis) {
$ERROR("'this' must be global object, got " + this); $DONE("'this' must be global object, got " + this);
return;
} }
if (arg !== obj) { 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, ...@@ -16,13 +16,17 @@ var expectedThis = undefined,
obj = {}; obj = {};
var p = Promise.reject(obj).then(function () { var p = Promise.reject(obj).then(function () {
$ERROR("Unexpected fulfillment; expected rejection."); $DONE("Unexpected fulfillment; expected rejection.");
}, function(arg) { }, function(arg) {
if (this !== expectedThis) { if (this !== expectedThis) {
$ERROR("'this' must be undefined, got " + this); $DONE("'this' must be undefined, got " + this);
return;
} }
if (arg !== obj) { 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 = {}; ...@@ -13,9 +13,11 @@ var obj = {};
var p = Promise.reject(obj).then(/*Identity, Thrower*/) var p = Promise.reject(obj).then(/*Identity, Thrower*/)
.then(function () { .then(function () {
$ERROR("Unexpected fulfillment - promise should reject."); $DONE("Unexpected fulfillment - promise should reject.");
}, function (arg) { }, function (arg) {
if (arg !== obj) { 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();
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment