Skip to content

Commit

Permalink
test: fix assert.strictEqual argument order
Browse files Browse the repository at this point in the history
PR-URL: #23518
Reviewed-By: Hitesh Kanwathirtha <digitalinfinity@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
  • Loading branch information
et4891 authored and jasnell committed Oct 17, 2018
1 parent f2c57e7 commit bd88c98
Showing 1 changed file with 61 additions and 61 deletions.
122 changes: 61 additions & 61 deletions test/addons-napi/test_conversions/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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)));
Expand All @@ -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);

0 comments on commit bd88c98

Please sign in to comment.