From 6f2feb01578c5a2cd5fb725de2a1e10d68027de3 Mon Sep 17 00:00:00 2001 From: Mike Pennisi Date: Mon, 22 Jun 2015 22:15:04 -0400 Subject: [PATCH 1/3] Fix bug in test This test's description concerns the behavior of `Promise.all` when the IteratorStep abstract operation fails due to an abrupt completion returned by the iterator's `next` method. The test body did not actually assert that functionality. Update the test body to correctly define the requisite iterator and assert that the specific error created is the one thrown from the invocation of `Promise.all` --- .../Promise/all/S25.4.4.1_A5.1_T1.js | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/test/built-ins/Promise/all/S25.4.4.1_A5.1_T1.js b/test/built-ins/Promise/all/S25.4.4.1_A5.1_T1.js index a46f0b6c17..ad138c0d1e 100644 --- a/test/built-ins/Promise/all/S25.4.4.1_A5.1_T1.js +++ b/test/built-ins/Promise/all/S25.4.4.1_A5.1_T1.js @@ -11,20 +11,17 @@ description: iterator.next throws, causing Promise.all to reject ---*/ var iterThrows = {}; -Object.defineProperty(iterThrows, Symbol.iterator, { - get: function () { - return { - next: function () { - throw new Error("abrupt completion"); - } - }; - } -}); +var error = new Test262Error(); +iterThrows[Symbol.iterator] = function() { + return { + next: function () { + throw error; + } + }; +}; Promise.all(iterThrows).then(function () { $ERROR('Promise unexpectedly resolved: Promise.all(iterThrows) should throw TypeError'); -},function (err) { - if (!(err instanceof TypeError)) { - $ERROR('Expected TypeError, got ' + err); - } +},function (reason) { + assert.sameValue(reason, error); }).then($DONE,$DONE); From 5e8b276bf5c55b8adcd764fa1f0d943410b3ec5d Mon Sep 17 00:00:00 2001 From: Mike Pennisi Date: Tue, 23 Jun 2015 12:03:09 -0400 Subject: [PATCH 2/3] fixup! Fix bug in test --- .../Promise/race/S25.4.4.3_A4.1_T1.js | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/test/built-ins/Promise/race/S25.4.4.3_A4.1_T1.js b/test/built-ins/Promise/race/S25.4.4.3_A4.1_T1.js index 33f499ac1c..4b846ebd4d 100644 --- a/test/built-ins/Promise/race/S25.4.4.3_A4.1_T1.js +++ b/test/built-ins/Promise/race/S25.4.4.3_A4.1_T1.js @@ -8,21 +8,18 @@ description: Promise.race rejects if IteratorStep throws ---*/ var iterThrows = {}; -Object.defineProperty(iterThrows, Symbol.iterator, { - get: function () { - return { - next: function () { - throw new Error("abrupt completion"); - } - }; - } -}); +var error = new Test262Error(); +iterThrows[Symbol.iterator] = function () { + return { + next: function () { + throw error; + } + }; +}; Promise.race(iterThrows).then(function () { $ERROR('Promise unexpectedly fulfilled: Promise.race(iterThrows) should throw TypeError'); -},function (err) { - if (!(err instanceof TypeError)) { - $ERROR('Expected TypeError, got ' + err); - } +}, function (reason) { + assert.sameValue(reason, error); }).then($DONE,$DONE); From ad064a631c5b0fe809f486d2aaca37c67202416c Mon Sep 17 00:00:00 2001 From: Mike Pennisi Date: Tue, 23 Jun 2015 13:42:19 -0400 Subject: [PATCH 3/3] fixup! Fix bug in test --- .../prototype/then/S25.4.5.3_A3.1_T1.js | 23 +++++++------------ 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/test/built-ins/Promise/prototype/then/S25.4.5.3_A3.1_T1.js b/test/built-ins/Promise/prototype/then/S25.4.5.3_A3.1_T1.js index 9c9eedd162..9df20f84e9 100644 --- a/test/built-ins/Promise/prototype/then/S25.4.5.3_A3.1_T1.js +++ b/test/built-ins/Promise/prototype/then/S25.4.5.3_A3.1_T1.js @@ -14,21 +14,14 @@ var p = Promise.resolve("foo"); Object.defineProperty(p, "constructor", { get: function () { - throw new Error("abrupt completion"); + throw new Test262Error(); } }); -try { - p.then(function () { - $ERROR("Should never be called."); - }, function () { - $ERROR("Should never be called."); - }); -} catch (e) { - if (!(e instanceof Error)) { - $ERROR("Expected Error, got " + e); - } - if (e.message !== "abrupt completion") { - $ERROR("Expected the Error we threw, got " + e); - } -} +assert.throws(Test262Error, function() { + p.then(function() { + $ERROR("Should never be called."); + }, function() { + $ERROR("Should never be called."); + }); +});