Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a801ffb

Browse filesBrowse files
Matt CrummeyFishrock123
authored andcommitted
test: refactor test-console
assert.equal() -> assert.strictEqual() PR-URL: #9873 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent bca587b commit a801ffb
Copy full SHA for a801ffb

File tree

Expand file treeCollapse file tree

1 file changed

+19
-17
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+19
-17
lines changed
Open diff view settings
Collapse file

‎test/parallel/test-console.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-console.js
+19-17Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ const assert = require('assert');
55
assert.ok(process.stdout.writable);
66
assert.ok(process.stderr.writable);
77
// Support legacy API
8-
assert.equal('number', typeof process.stdout.fd);
9-
assert.equal('number', typeof process.stderr.fd);
8+
assert.strictEqual('number', typeof process.stdout.fd);
9+
assert.strictEqual('number', typeof process.stderr.fd);
1010

1111
assert.doesNotThrow(function() {
1212
process.once('warning', common.mustCall((warning) => {
@@ -35,28 +35,28 @@ global.process.stderr.write = function(string) {
3535
errStrings.push(string);
3636
};
3737

38-
// test console.log()
38+
// test console.log() goes to stdout
3939
console.log('foo');
4040
console.log('foo', 'bar');
4141
console.log('%s %s', 'foo', 'bar', 'hop');
4242
console.log({slashes: '\\\\'});
4343
console.log(custom_inspect);
4444

45-
// test console.info()
45+
// test console.info() goes to stdout
4646
console.info('foo');
4747
console.info('foo', 'bar');
4848
console.info('%s %s', 'foo', 'bar', 'hop');
4949
console.info({slashes: '\\\\'});
5050
console.info(custom_inspect);
5151

52-
// test console.error()
52+
// test console.error() goes to stderr
5353
console.error('foo');
5454
console.error('foo', 'bar');
5555
console.error('%s %s', 'foo', 'bar', 'hop');
5656
console.error({slashes: '\\\\'});
5757
console.error(custom_inspect);
5858

59-
// test console.warn()
59+
// test console.warn() goes to stderr
6060
console.warn('foo');
6161
console.warn('foo', 'bar');
6262
console.warn('%s %s', 'foo', 'bar', 'hop');
@@ -102,29 +102,31 @@ const expectedStrings = [
102102
];
103103

104104
for (const expected of expectedStrings) {
105-
assert.equal(expected + '\n', strings.shift()); // console.log (stdout)
106-
assert.equal(expected + '\n', errStrings.shift()); // console.error (stderr)
105+
assert.strictEqual(expected + '\n', strings.shift());
106+
assert.strictEqual(expected + '\n', errStrings.shift());
107107
}
108108

109109
for (const expected of expectedStrings) {
110-
assert.equal(expected + '\n', strings.shift()); // console.info (stdout)
111-
assert.equal(expected + '\n', errStrings.shift()); // console.warn (stderr)
110+
assert.strictEqual(expected + '\n', strings.shift());
111+
assert.strictEqual(expected + '\n', errStrings.shift());
112112
}
113113

114-
assert.equal("{ foo: 'bar', inspect: [Function: inspect] }\n", strings.shift());
115-
assert.equal("{ foo: 'bar', inspect: [Function: inspect] }\n", strings.shift());
114+
assert.strictEqual("{ foo: 'bar', inspect: [Function: inspect] }\n",
115+
strings.shift());
116+
assert.strictEqual("{ foo: 'bar', inspect: [Function: inspect] }\n",
117+
strings.shift());
116118
assert.notEqual(-1, strings.shift().indexOf('foo: [Object]'));
117-
assert.equal(-1, strings.shift().indexOf('baz'));
119+
assert.strictEqual(-1, strings.shift().indexOf('baz'));
118120
assert.ok(/^label: \d+\.\d{3}ms$/.test(strings.shift().trim()));
119121
assert.ok(/^__proto__: \d+\.\d{3}ms$/.test(strings.shift().trim()));
120122
assert.ok(/^constructor: \d+\.\d{3}ms$/.test(strings.shift().trim()));
121123
assert.ok(/^hasOwnProperty: \d+\.\d{3}ms$/.test(strings.shift().trim()));
122124

123-
assert.equal('Trace: This is a {"formatted":"trace"} 10 foo',
124-
errStrings.shift().split('\n').shift());
125+
assert.strictEqual('Trace: This is a {"formatted":"trace"} 10 foo',
126+
errStrings.shift().split('\n').shift());
125127

126-
assert.equal(strings.length, 0);
127-
assert.equal(errStrings.length, 0);
128+
assert.strictEqual(strings.length, 0);
129+
assert.strictEqual(errStrings.length, 0);
128130

129131
assert.throws(() => {
130132
console.assert(false, 'should throw');

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.