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 4244080

Browse filesBrowse files
BridgeARMylesBorins
authored andcommitted
test: stricten readline keypress failure test condition
This verifies that the thrown error is the expected one. That was not tested before. PR-URL: #31300 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent 49364b0 commit 4244080
Copy full SHA for 4244080

File tree

Expand file treeCollapse file tree

1 file changed

+9
-4
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+9
-4
lines changed
Open diff view settings
Collapse file

‎test/parallel/test-readline-interface.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-readline-interface.js
+9-4Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -561,15 +561,20 @@ function isWarned(emitter) {
561561
{ input: fi, output: fi, terminal: true }
562562
);
563563
const keys = [];
564+
const err = new Error('bad thing happened');
564565
fi.on('keypress', function(key) {
565566
keys.push(key);
566567
if (key === 'X') {
567-
throw new Error('bad thing happened');
568+
throw err;
568569
}
569570
});
570-
try {
571-
fi.emit('data', 'fooX');
572-
} catch { }
571+
assert.throws(
572+
() => fi.emit('data', 'fooX'),
573+
(e) => {
574+
assert.strictEqual(e, err);
575+
return true;
576+
}
577+
);
573578
fi.emit('data', 'bar');
574579
assert.strictEqual(keys.join(''), 'fooXbar');
575580
rli.close();

0 commit comments

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