Skip to content

Commit

Permalink
test: reversed params in assert.strictEqual()
Browse files Browse the repository at this point in the history
Reversed parameters of assert.strictEqual() in
test-promises-unhandled-rejections.js so that first one is actual and
second one is expected value.

PR-URL: #23591
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
  • Loading branch information
durad authored and jasnell committed Oct 21, 2018
1 parent a144d64 commit c55f25a
Showing 1 changed file with 39 additions and 39 deletions.
78 changes: 39 additions & 39 deletions test/parallel/test-promises-unhandled-rejections.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ asyncTest('synchronously rejected promise should trigger' +
' unhandledRejection', function(done) {
const e = new Error();
onUnhandledSucceed(done, function(reason, promise) {
assert.strictEqual(e, reason);
assert.strictEqual(reason, e);
});
Promise.reject(e);
});
Expand All @@ -121,7 +121,7 @@ asyncTest('synchronously rejected promise should trigger' +
' unhandledRejection', function(done) {
const e = new Error();
onUnhandledSucceed(done, function(reason, promise) {
assert.strictEqual(e, reason);
assert.strictEqual(reason, e);
});
new Promise(function(_, reject) {
reject(e);
Expand All @@ -132,7 +132,7 @@ asyncTest('Promise rejected after setImmediate should trigger' +
' unhandledRejection', function(done) {
const e = new Error();
onUnhandledSucceed(done, function(reason, promise) {
assert.strictEqual(e, reason);
assert.strictEqual(reason, e);
});
new Promise(function(_, reject) {
setImmediate(function() {
Expand All @@ -145,7 +145,7 @@ asyncTest('Promise rejected after setTimeout(,1) should trigger' +
' unhandled rejection', function(done) {
const e = new Error();
onUnhandledSucceed(done, function(reason, promise) {
assert.strictEqual(e, reason);
assert.strictEqual(reason, e);
});
new Promise(function(_, reject) {
setTimeout(function() {
Expand All @@ -158,7 +158,7 @@ asyncTest('Catching a promise rejection after setImmediate is not' +
' soon enough to stop unhandledRejection', function(done) {
const e = new Error();
onUnhandledSucceed(done, function(reason, promise) {
assert.strictEqual(e, reason);
assert.strictEqual(reason, e);
});
let _reject;
const promise = new Promise(function(_, reject) {
Expand All @@ -175,11 +175,11 @@ asyncTest('When re-throwing new errors in a promise catch, only the' +
const e = new Error();
const e2 = new Error();
onUnhandledSucceed(done, function(reason, promise) {
assert.strictEqual(e2, reason);
assert.strictEqual(promise2, promise);
assert.strictEqual(reason, e2);
assert.strictEqual(promise, promise2);
});
const promise2 = Promise.reject(e).then(assert.fail, function(reason) {
assert.strictEqual(e, reason);
assert.strictEqual(reason, e);
throw e2;
});
});
Expand All @@ -188,7 +188,7 @@ asyncTest('Test params of unhandledRejection for a synchronously-rejected ' +
'promise', function(done) {
const e = new Error();
onUnhandledSucceed(done, function(reason, promise) {
assert.strictEqual(e, reason);
assert.strictEqual(reason, e);
assert.strictEqual(promise, promise);
});
Promise.reject(e);
Expand All @@ -200,15 +200,15 @@ asyncTest('When re-throwing new errors in a promise catch, only the ' +
const e = new Error();
const e2 = new Error();
onUnhandledSucceed(done, function(reason, promise) {
assert.strictEqual(e2, reason);
assert.strictEqual(promise2, promise);
assert.strictEqual(reason, e2);
assert.strictEqual(promise, promise2);
});
const promise2 = new Promise(function(_, reject) {
setTimeout(function() {
reject(e);
}, 1);
}).then(assert.fail, function(reason) {
assert.strictEqual(e, reason);
assert.strictEqual(reason, e);
throw e2;
});
});
Expand All @@ -219,15 +219,15 @@ asyncTest('When re-throwing new errors in a promise catch, only the re-thrown' +
const e = new Error();
const e2 = new Error();
onUnhandledSucceed(done, function(reason, promise) {
assert.strictEqual(e2, reason);
assert.strictEqual(promise2, promise);
assert.strictEqual(reason, e2);
assert.strictEqual(promise, promise2);
});
const promise = new Promise(function(_, reject) {
setTimeout(function() {
reject(e);
process.nextTick(function() {
promise2 = promise.then(assert.fail, function(reason) {
assert.strictEqual(e, reason);
assert.strictEqual(reason, e);
throw e2;
});
});
Expand Down Expand Up @@ -308,7 +308,7 @@ asyncTest('catching a promise which is asynchronously rejected (via ' +
}, 1);
});
}).then(assert.fail, function(reason) {
assert.strictEqual(e, reason);
assert.strictEqual(reason, e);
});
});

Expand All @@ -319,7 +319,7 @@ asyncTest('Catching a rejected promise derived from throwing in a' +
Promise.resolve().then(function() {
throw e;
}).then(assert.fail, function(reason) {
assert.strictEqual(e, reason);
assert.strictEqual(reason, e);
});
});

Expand All @@ -331,7 +331,7 @@ asyncTest('Catching a rejected promise derived from returning a' +
Promise.resolve().then(function() {
return Promise.reject(e);
}).then(assert.fail, function(reason) {
assert.strictEqual(e, reason);
assert.strictEqual(reason, e);
});
});

Expand All @@ -340,8 +340,8 @@ asyncTest('A rejected promise derived from returning an' +
' does trigger unhandledRejection', function(done) {
const e = new Error();
onUnhandledSucceed(done, function(reason, promise) {
assert.strictEqual(e, reason);
assert.strictEqual(_promise, promise);
assert.strictEqual(reason, e);
assert.strictEqual(promise, _promise);
});
const _promise = Promise.resolve().then(function() {
return new Promise(function(_, reject) {
Expand All @@ -356,8 +356,8 @@ asyncTest('A rejected promise derived from throwing in a fulfillment handler' +
' does trigger unhandledRejection', function(done) {
const e = new Error();
onUnhandledSucceed(done, function(reason, promise) {
assert.strictEqual(e, reason);
assert.strictEqual(_promise, promise);
assert.strictEqual(reason, e);
assert.strictEqual(promise, _promise);
});
const _promise = Promise.resolve().then(function() {
throw e;
Expand All @@ -370,8 +370,8 @@ asyncTest(
function(done) {
const e = new Error();
onUnhandledSucceed(done, function(reason, promise) {
assert.strictEqual(e, reason);
assert.strictEqual(_promise, promise);
assert.strictEqual(reason, e);
assert.strictEqual(promise, _promise);
});
const _promise = Promise.resolve().then(function() {
return Promise.reject(e);
Expand Down Expand Up @@ -410,8 +410,8 @@ asyncTest('Failing to catch the Promise.all() of a collection that includes' +
' promise, not the passed promise', function(done) {
const e = new Error();
onUnhandledSucceed(done, function(reason, promise) {
assert.strictEqual(e, reason);
assert.strictEqual(p, promise);
assert.strictEqual(reason, e);
assert.strictEqual(promise, p);
});
const p = Promise.all([Promise.reject(e)]);
});
Expand All @@ -422,13 +422,13 @@ asyncTest('Waiting setTimeout(, 10) to catch a promise causes an' +
const unhandledPromises = [];
const e = new Error();
process.on('unhandledRejection', function(reason, promise) {
assert.strictEqual(e, reason);
assert.strictEqual(reason, e);
unhandledPromises.push(promise);
});
process.on('rejectionHandled', function(promise) {
assert.strictEqual(1, unhandledPromises.length);
assert.strictEqual(unhandledPromises.length, 1);
assert.strictEqual(unhandledPromises[0], promise);
assert.strictEqual(thePromise, promise);
assert.strictEqual(promise, thePromise);
done();
});

Expand All @@ -437,7 +437,7 @@ asyncTest('Waiting setTimeout(, 10) to catch a promise causes an' +
});
setTimeout(function() {
thePromise.then(assert.fail, function(reason) {
assert.strictEqual(e, reason);
assert.strictEqual(reason, e);
});
}, 10);
});
Expand Down Expand Up @@ -568,8 +568,8 @@ asyncTest('setImmediate + promise microtasks is too late to attach a catch' +
' (setImmediate before promise creation/rejection)', function(done) {
const e = new Error();
onUnhandledSucceed(done, function(reason, promise) {
assert.strictEqual(e, reason);
assert.strictEqual(p, promise);
assert.strictEqual(reason, e);
assert.strictEqual(promise, p);
});
const p = Promise.reject(e);
setImmediate(function() {
Expand All @@ -583,8 +583,8 @@ asyncTest('setImmediate + promise microtasks is too late to attach a catch' +
' handler; unhandledRejection will be triggered in that case' +
' (setImmediate before promise creation/rejection)', function(done) {
onUnhandledSucceed(done, function(reason, promise) {
assert.strictEqual(undefined, reason);
assert.strictEqual(p, promise);
assert.strictEqual(reason, undefined);
assert.strictEqual(promise, p);
});
setImmediate(function() {
Promise.resolve().then(function() {
Expand All @@ -604,8 +604,8 @@ asyncTest('setImmediate + promise microtasks is too late to attach a catch' +
' handler; unhandledRejection will be triggered in that case' +
' (setImmediate after promise creation/rejection)', function(done) {
onUnhandledSucceed(done, function(reason, promise) {
assert.strictEqual(undefined, reason);
assert.strictEqual(p, promise);
assert.strictEqual(reason, undefined);
assert.strictEqual(promise, p);
});
const p = Promise.reject();
setImmediate(function() {
Expand Down Expand Up @@ -634,8 +634,8 @@ asyncTest(
const e = new Error('error');
const domainError = new Error('domain error');
onUnhandledSucceed(done, function(reason, promise) {
assert.strictEqual(reason, e);
assert.strictEqual(domainReceivedError, domainError);
assert.strictEqual(e, reason);
assert.strictEqual(domainError, domainReceivedError);
});
Promise.reject(e);
process.nextTick(function() {
Expand Down Expand Up @@ -670,7 +670,7 @@ asyncTest('Throwing an error inside a rejectionHandled handler goes to' +
const e = new Error();
const e2 = new Error();
const tearDownException = setupException(function(err) {
assert.strictEqual(e2, err);
assert.strictEqual(err, e2);
tearDownException();
done();
});
Expand Down

0 comments on commit c55f25a

Please sign in to comment.