From a801ffb1ee53ff40d173eee22f8622c1c1f685d0 Mon Sep 17 00:00:00 2001 From: Matt Crummey Date: Thu, 1 Dec 2016 15:43:15 +0000 Subject: [PATCH] test: refactor test-console assert.equal() -> assert.strictEqual() PR-URL: https://github.com/nodejs/node/pull/9873 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell --- test/parallel/test-console.js | 36 ++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/test/parallel/test-console.js b/test/parallel/test-console.js index 2c8a498a331b55..ee7170bd9101ac 100644 --- a/test/parallel/test-console.js +++ b/test/parallel/test-console.js @@ -5,8 +5,8 @@ const assert = require('assert'); assert.ok(process.stdout.writable); assert.ok(process.stderr.writable); // Support legacy API -assert.equal('number', typeof process.stdout.fd); -assert.equal('number', typeof process.stderr.fd); +assert.strictEqual('number', typeof process.stdout.fd); +assert.strictEqual('number', typeof process.stderr.fd); assert.doesNotThrow(function() { process.once('warning', common.mustCall((warning) => { @@ -35,28 +35,28 @@ global.process.stderr.write = function(string) { errStrings.push(string); }; -// test console.log() +// test console.log() goes to stdout console.log('foo'); console.log('foo', 'bar'); console.log('%s %s', 'foo', 'bar', 'hop'); console.log({slashes: '\\\\'}); console.log(custom_inspect); -// test console.info() +// test console.info() goes to stdout console.info('foo'); console.info('foo', 'bar'); console.info('%s %s', 'foo', 'bar', 'hop'); console.info({slashes: '\\\\'}); console.info(custom_inspect); -// test console.error() +// test console.error() goes to stderr console.error('foo'); console.error('foo', 'bar'); console.error('%s %s', 'foo', 'bar', 'hop'); console.error({slashes: '\\\\'}); console.error(custom_inspect); -// test console.warn() +// test console.warn() goes to stderr console.warn('foo'); console.warn('foo', 'bar'); console.warn('%s %s', 'foo', 'bar', 'hop'); @@ -102,29 +102,31 @@ const expectedStrings = [ ]; for (const expected of expectedStrings) { - assert.equal(expected + '\n', strings.shift()); // console.log (stdout) - assert.equal(expected + '\n', errStrings.shift()); // console.error (stderr) + assert.strictEqual(expected + '\n', strings.shift()); + assert.strictEqual(expected + '\n', errStrings.shift()); } for (const expected of expectedStrings) { - assert.equal(expected + '\n', strings.shift()); // console.info (stdout) - assert.equal(expected + '\n', errStrings.shift()); // console.warn (stderr) + assert.strictEqual(expected + '\n', strings.shift()); + assert.strictEqual(expected + '\n', errStrings.shift()); } -assert.equal("{ foo: 'bar', inspect: [Function: inspect] }\n", strings.shift()); -assert.equal("{ foo: 'bar', inspect: [Function: inspect] }\n", strings.shift()); +assert.strictEqual("{ foo: 'bar', inspect: [Function: inspect] }\n", + strings.shift()); +assert.strictEqual("{ foo: 'bar', inspect: [Function: inspect] }\n", + strings.shift()); assert.notEqual(-1, strings.shift().indexOf('foo: [Object]')); -assert.equal(-1, strings.shift().indexOf('baz')); +assert.strictEqual(-1, strings.shift().indexOf('baz')); assert.ok(/^label: \d+\.\d{3}ms$/.test(strings.shift().trim())); assert.ok(/^__proto__: \d+\.\d{3}ms$/.test(strings.shift().trim())); assert.ok(/^constructor: \d+\.\d{3}ms$/.test(strings.shift().trim())); assert.ok(/^hasOwnProperty: \d+\.\d{3}ms$/.test(strings.shift().trim())); -assert.equal('Trace: This is a {"formatted":"trace"} 10 foo', - errStrings.shift().split('\n').shift()); +assert.strictEqual('Trace: This is a {"formatted":"trace"} 10 foo', + errStrings.shift().split('\n').shift()); -assert.equal(strings.length, 0); -assert.equal(errStrings.length, 0); +assert.strictEqual(strings.length, 0); +assert.strictEqual(errStrings.length, 0); assert.throws(() => { console.assert(false, 'should throw');