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 aa4b028

Browse filesBrowse files
vinimdocarmoItalo A. Casas
authored andcommitted
test: improve test-fs-open-flags
* use arrow funcion instead of function expression * add second argument to method assert.throws * check error messages from beginning to the end using ^ and $ PR-URL: #10908 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Adrian Estrada <edsadr@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent 35d6659 commit aa4b028
Copy full SHA for aa4b028

File tree

Expand file treeCollapse file tree

1 file changed

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

1 file changed

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

‎test/parallel/test-fs-open-flags.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-fs-open-flags.js
+11-4Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,27 @@ assert.equal(stringToFlags('xa+'), O_APPEND | O_CREAT | O_RDWR | O_EXCL);
3434
('+ +a +r +w rw wa war raw r++ a++ w++ x +x x+ rx rx+ wxx wax xwx xxx')
3535
.split(' ')
3636
.forEach(function(flags) {
37-
assert.throws(function() { stringToFlags(flags); });
37+
assert.throws(
38+
() => stringToFlags(flags),
39+
new RegExp(`^Error: Unknown file open flag: ${escapeRegExp(flags)}`)
40+
);
3841
});
3942

4043
assert.throws(
4144
() => stringToFlags({}),
42-
/Unknown file open flag: \[object Object\]/
45+
/^Error: Unknown file open flag: \[object Object\]$/
4346
);
4447

4548
assert.throws(
4649
() => stringToFlags(true),
47-
/Unknown file open flag: true/
50+
/^Error: Unknown file open flag: true$/
4851
);
4952

5053
assert.throws(
5154
() => stringToFlags(null),
52-
/Unknown file open flag: null/
55+
/^Error: Unknown file open flag: null$/
5356
);
57+
58+
function escapeRegExp(string) {
59+
return string.replace(/[\\^$*+?.()|[\]{}]/g, '\\$&');
60+
}

0 commit comments

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