Skip to content

Commit

Permalink
test: remove string literals from assert.strictEqual() calls
Browse files Browse the repository at this point in the history
In test/parallel/test-intl.js, five calls to assert.strictEqual() use a
third, string-literal parameter, which specifies a message to display
when the assertion fails. The problem is that if the assertion fails,
the error message will show the string literal but not the values that
caused the assertion to fail.

This commit removes the third parameter from the five calls and makes
them comments above the assertions instead. The default error message
produced by assert.strictEqual() shows the values that caused the
assertion to fail, which should be somewhat more helpful.

PR-URL: #21211
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
  • Loading branch information
kylstraj authored and targos committed Jun 11, 2018
1 parent e7dcc23 commit 45d2716
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions test/parallel/test-intl.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,14 @@ if (!common.hasIntl) {
const collOpts = { sensitivity: 'base', ignorePunctuation: true };
const coll = new Intl.Collator(['en'], collOpts);

assert.strictEqual(coll.compare('blackbird', 'black-bird'), 0,
'ignore punctuation failed');
assert.strictEqual(coll.compare('blackbird', 'red-bird'), -1,
'compare less failed');
assert.strictEqual(coll.compare('bluebird', 'blackbird'), 1,
'compare greater failed');
assert.strictEqual(coll.compare('Bluebird', 'bluebird'), 0,
'ignore case failed');
assert.strictEqual(coll.compare('\ufb03', 'ffi'), 0,
'ffi ligature (contraction) failed');
// ignore punctuation
assert.strictEqual(coll.compare('blackbird', 'black-bird'), 0);
// compare less
assert.strictEqual(coll.compare('blackbird', 'red-bird'), -1);
// compare greater
assert.strictEqual(coll.compare('bluebird', 'blackbird'), 1);
// ignore case
assert.strictEqual(coll.compare('Bluebird', 'bluebird'), 0);
// ffi ligature (contraction)
assert.strictEqual(coll.compare('\ufb03', 'ffi'), 0);
}

0 comments on commit 45d2716

Please sign in to comment.