From 5f2ba2522f17fc086f511bf6109ade08d8681c78 Mon Sep 17 00:00:00 2001 From: Mike Pennisi <mike@mikepennisi.com> Date: Mon, 28 Dec 2015 17:14:32 -0500 Subject: [PATCH] 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. --- .../then/rxn-handler-fulfilled-invoke-nonstrict.js | 13 ++++++++++--- .../then/rxn-handler-fulfilled-invoke-strict.js | 13 ++++++++++--- .../Promise/prototype/then/rxn-handler-identity.js | 8 ++++++-- .../then/rxn-handler-rejected-invoke-nonstrict.js | 12 ++++++++---- .../then/rxn-handler-rejected-invoke-strict.js | 12 ++++++++---- .../Promise/prototype/then/rxn-handler-thrower.js | 8 +++++--- 6 files changed, 47 insertions(+), 19 deletions(-) diff --git a/test/built-ins/Promise/prototype/then/rxn-handler-fulfilled-invoke-nonstrict.js b/test/built-ins/Promise/prototype/then/rxn-handler-fulfilled-invoke-nonstrict.js index 2d3d8ee3ee..db9e7a11d8 100644 --- a/test/built-ins/Promise/prototype/then/rxn-handler-fulfilled-invoke-nonstrict.js +++ b/test/built-ins/Promise/prototype/then/rxn-handler-fulfilled-invoke-nonstrict.js @@ -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.'); +}); diff --git a/test/built-ins/Promise/prototype/then/rxn-handler-fulfilled-invoke-strict.js b/test/built-ins/Promise/prototype/then/rxn-handler-fulfilled-invoke-strict.js index a843cf5a55..f79ea81284 100644 --- a/test/built-ins/Promise/prototype/then/rxn-handler-fulfilled-invoke-strict.js +++ b/test/built-ins/Promise/prototype/then/rxn-handler-fulfilled-invoke-strict.js @@ -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.'); +}); diff --git a/test/built-ins/Promise/prototype/then/rxn-handler-identity.js b/test/built-ins/Promise/prototype/then/rxn-handler-identity.js index d5bf88f39c..6230f9c9be 100644 --- a/test/built-ins/Promise/prototype/then/rxn-handler-identity.js +++ b/test/built-ins/Promise/prototype/then/rxn-handler-identity.js @@ -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.'); + }); diff --git a/test/built-ins/Promise/prototype/then/rxn-handler-rejected-invoke-nonstrict.js b/test/built-ins/Promise/prototype/then/rxn-handler-rejected-invoke-nonstrict.js index dccad16d4d..078bbe2d5b 100644 --- a/test/built-ins/Promise/prototype/then/rxn-handler-rejected-invoke-nonstrict.js +++ b/test/built-ins/Promise/prototype/then/rxn-handler-rejected-invoke-nonstrict.js @@ -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(); +}); diff --git a/test/built-ins/Promise/prototype/then/rxn-handler-rejected-invoke-strict.js b/test/built-ins/Promise/prototype/then/rxn-handler-rejected-invoke-strict.js index 7ef2666b78..2736556e3a 100644 --- a/test/built-ins/Promise/prototype/then/rxn-handler-rejected-invoke-strict.js +++ b/test/built-ins/Promise/prototype/then/rxn-handler-rejected-invoke-strict.js @@ -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(); +}); diff --git a/test/built-ins/Promise/prototype/then/rxn-handler-thrower.js b/test/built-ins/Promise/prototype/then/rxn-handler-thrower.js index 4c6eb97639..437792f970 100644 --- a/test/built-ins/Promise/prototype/then/rxn-handler-thrower.js +++ b/test/built-ins/Promise/prototype/then/rxn-handler-thrower.js @@ -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(); + }); -- GitLab