From b2e173be4852e0acd665c61f4e8d50a1e5b7f70d Mon Sep 17 00:00:00 2001 From: et4891 Date: Fri, 12 Oct 2018 10:30:13 -0700 Subject: [PATCH] test: fix assert.strictEqual argument order PR-URL: https://github.com/nodejs/node/pull/23518 Reviewed-By: Hitesh Kanwathirtha Reviewed-By: Trivikram Kamat Reviewed-By: James M Snell Reviewed-By: Gireesh Punathil --- test/addons-napi/test_conversions/test.js | 122 +++++++++++----------- 1 file changed, 61 insertions(+), 61 deletions(-) diff --git a/test/addons-napi/test_conversions/test.js b/test/addons-napi/test_conversions/test.js index 27e1fb322c4c47..b9e43da0c5ed20 100644 --- a/test/addons-napi/test_conversions/test.js +++ b/test/addons-napi/test_conversions/test.js @@ -9,8 +9,8 @@ const stringExpected = /string was expected/; const testSym = Symbol('test'); -assert.strictEqual(false, test.asBool(false)); -assert.strictEqual(true, test.asBool(true)); +assert.strictEqual(test.asBool(false), false); +assert.strictEqual(test.asBool(true), true); assert.throws(() => test.asBool(undefined), boolExpected); assert.throws(() => test.asBool(null), boolExpected); assert.throws(() => test.asBool(Number.NaN), boolExpected); @@ -25,14 +25,14 @@ assert.throws(() => test.asBool([]), boolExpected); assert.throws(() => test.asBool(testSym), boolExpected); [test.asInt32, test.asUInt32, test.asInt64].forEach((asInt) => { - assert.strictEqual(0, asInt(0)); - assert.strictEqual(1, asInt(1)); - assert.strictEqual(1, asInt(1.0)); - assert.strictEqual(1, asInt(1.1)); - assert.strictEqual(1, asInt(1.9)); - assert.strictEqual(0, asInt(0.9)); - assert.strictEqual(999, asInt(999.9)); - assert.strictEqual(0, asInt(Number.NaN)); + assert.strictEqual(asInt(0), 0); + assert.strictEqual(asInt(1), 1); + assert.strictEqual(asInt(1.0), 1); + assert.strictEqual(asInt(1.1), 1); + assert.strictEqual(asInt(1.9), 1); + assert.strictEqual(asInt(0.9), 0); + assert.strictEqual(asInt(999.9), 999); + assert.strictEqual(asInt(Number.NaN), 0); assert.throws(() => asInt(undefined), numberExpected); assert.throws(() => asInt(null), numberExpected); assert.throws(() => asInt(false), numberExpected); @@ -43,18 +43,18 @@ assert.throws(() => test.asBool(testSym), boolExpected); assert.throws(() => asInt(testSym), numberExpected); }); -assert.strictEqual(-1, test.asInt32(-1)); -assert.strictEqual(-1, test.asInt64(-1)); -assert.strictEqual(Math.pow(2, 32) - 1, test.asUInt32(-1)); +assert.strictEqual(test.asInt32(-1), -1); +assert.strictEqual(test.asInt64(-1), -1); +assert.strictEqual(test.asUInt32(-1), Math.pow(2, 32) - 1); -assert.strictEqual(0, test.asDouble(0)); -assert.strictEqual(1, test.asDouble(1)); -assert.strictEqual(1.0, test.asDouble(1.0)); -assert.strictEqual(1.1, test.asDouble(1.1)); -assert.strictEqual(1.9, test.asDouble(1.9)); -assert.strictEqual(0.9, test.asDouble(0.9)); -assert.strictEqual(999.9, test.asDouble(999.9)); -assert.strictEqual(-1, test.asDouble(-1)); +assert.strictEqual(test.asDouble(0), 0); +assert.strictEqual(test.asDouble(1), 1); +assert.strictEqual(test.asDouble(1.0), 1.0); +assert.strictEqual(test.asDouble(1.1), 1.1); +assert.strictEqual(test.asDouble(1.9), 1.9); +assert.strictEqual(test.asDouble(0.9), 0.9); +assert.strictEqual(test.asDouble(999.9), 999.9); +assert.strictEqual(test.asDouble(-1), -1); assert.ok(Number.isNaN(test.asDouble(Number.NaN))); assert.throws(() => test.asDouble(undefined), numberExpected); assert.throws(() => test.asDouble(null), numberExpected); @@ -65,8 +65,8 @@ assert.throws(() => test.asDouble({}), numberExpected); assert.throws(() => test.asDouble([]), numberExpected); assert.throws(() => test.asDouble(testSym), numberExpected); -assert.strictEqual('', test.asString('')); -assert.strictEqual('test', test.asString('test')); +assert.strictEqual(test.asString(''), ''); +assert.strictEqual(test.asString('test'), 'test'); assert.throws(() => test.asString(undefined), stringExpected); assert.throws(() => test.asString(null), stringExpected); assert.throws(() => test.asString(false), stringExpected); @@ -77,32 +77,32 @@ assert.throws(() => test.asString({}), stringExpected); assert.throws(() => test.asString([]), stringExpected); assert.throws(() => test.asString(testSym), stringExpected); -assert.strictEqual(true, test.toBool(true)); -assert.strictEqual(true, test.toBool(1)); -assert.strictEqual(true, test.toBool(-1)); -assert.strictEqual(true, test.toBool('true')); -assert.strictEqual(true, test.toBool('false')); -assert.strictEqual(true, test.toBool({})); -assert.strictEqual(true, test.toBool([])); -assert.strictEqual(true, test.toBool(testSym)); -assert.strictEqual(false, test.toBool(false)); -assert.strictEqual(false, test.toBool(undefined)); -assert.strictEqual(false, test.toBool(null)); -assert.strictEqual(false, test.toBool(0)); -assert.strictEqual(false, test.toBool(Number.NaN)); -assert.strictEqual(false, test.toBool('')); +assert.strictEqual(test.toBool(true), true); +assert.strictEqual(test.toBool(1), true); +assert.strictEqual(test.toBool(-1), true); +assert.strictEqual(test.toBool('true'), true); +assert.strictEqual(test.toBool('false'), true); +assert.strictEqual(test.toBool({}), true); +assert.strictEqual(test.toBool([]), true); +assert.strictEqual(test.toBool(testSym), true); +assert.strictEqual(test.toBool(false), false); +assert.strictEqual(test.toBool(undefined), false); +assert.strictEqual(test.toBool(null), false); +assert.strictEqual(test.toBool(0), false); +assert.strictEqual(test.toBool(Number.NaN), false); +assert.strictEqual(test.toBool(''), false); -assert.strictEqual(0, test.toNumber(0)); -assert.strictEqual(1, test.toNumber(1)); -assert.strictEqual(1.1, test.toNumber(1.1)); -assert.strictEqual(-1, test.toNumber(-1)); -assert.strictEqual(0, test.toNumber('0')); -assert.strictEqual(1, test.toNumber('1')); -assert.strictEqual(1.1, test.toNumber('1.1')); -assert.strictEqual(0, test.toNumber([])); -assert.strictEqual(0, test.toNumber(false)); -assert.strictEqual(0, test.toNumber(null)); -assert.strictEqual(0, test.toNumber('')); +assert.strictEqual(test.toNumber(0), 0); +assert.strictEqual(test.toNumber(1), 1); +assert.strictEqual(test.toNumber(1.1), 1.1); +assert.strictEqual(test.toNumber(-1), -1); +assert.strictEqual(test.toNumber('0'), 0); +assert.strictEqual(test.toNumber('1'), 1); +assert.strictEqual(test.toNumber('1.1'), 1.1); +assert.strictEqual(test.toNumber([]), 0); +assert.strictEqual(test.toNumber(false), 0); +assert.strictEqual(test.toNumber(null), 0); +assert.strictEqual(test.toNumber(''), 0); assert.ok(Number.isNaN(test.toNumber(Number.NaN))); assert.ok(Number.isNaN(test.toNumber({}))); assert.ok(Number.isNaN(test.toNumber(undefined))); @@ -124,17 +124,17 @@ assert.notDeepStrictEqual(test.toObject(''), ''); assert.notDeepStrictEqual(test.toObject(0), 0); assert.ok(!Number.isNaN(test.toObject(Number.NaN))); -assert.strictEqual('', test.toString('')); -assert.strictEqual('test', test.toString('test')); -assert.strictEqual('undefined', test.toString(undefined)); -assert.strictEqual('null', test.toString(null)); -assert.strictEqual('false', test.toString(false)); -assert.strictEqual('true', test.toString(true)); -assert.strictEqual('0', test.toString(0)); -assert.strictEqual('1.1', test.toString(1.1)); -assert.strictEqual('NaN', test.toString(Number.NaN)); -assert.strictEqual('[object Object]', test.toString({})); -assert.strictEqual('test', test.toString({ toString: () => 'test' })); -assert.strictEqual('', test.toString([])); -assert.strictEqual('1,2,3', test.toString([ 1, 2, 3 ])); +assert.strictEqual(test.toString(''), ''); +assert.strictEqual(test.toString('test'), 'test'); +assert.strictEqual(test.toString(undefined), 'undefined'); +assert.strictEqual(test.toString(null), 'null'); +assert.strictEqual(test.toString(false), 'false'); +assert.strictEqual(test.toString(true), 'true'); +assert.strictEqual(test.toString(0), '0'); +assert.strictEqual(test.toString(1.1), '1.1'); +assert.strictEqual(test.toString(Number.NaN), 'NaN'); +assert.strictEqual(test.toString({}), '[object Object]'); +assert.strictEqual(test.toString({ toString: () => 'test' }), 'test'); +assert.strictEqual(test.toString([]), ''); +assert.strictEqual(test.toString([ 1, 2, 3 ]), '1,2,3'); assert.throws(() => test.toString(testSym), TypeError);