Skip to content

Commit 15c71f6

Browse files
edsadritaloacasas
authored andcommitted
test: improve code in test-fs-open.js
* use const and let instead of var * use assert.strictEqual instead of assert.equal * use assert.strictEqual instead of assert.ok * use assert.ifError PR-URL: #10312 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Italo A. Casas <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Santiago Gimeno <[email protected]>
1 parent a308a2f commit 15c71f6

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

test/parallel/test-fs-open.js

+10-13
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,24 @@
11
'use strict';
22
const common = require('../common');
3-
var assert = require('assert');
4-
var fs = require('fs');
3+
const assert = require('assert');
4+
const fs = require('fs');
5+
6+
let caughtException = false;
57

6-
var caughtException = false;
78
try {
89
// should throw ENOENT, not EBADF
910
// see https://github.com/joyent/node/pull/1228
1011
fs.openSync('/path/to/file/that/does/not/exist', 'r');
1112
} catch (e) {
12-
assert.equal(e.code, 'ENOENT');
13+
assert.strictEqual(e.code, 'ENOENT');
1314
caughtException = true;
1415
}
15-
assert.ok(caughtException);
16+
assert.strictEqual(caughtException, true);
1617

17-
fs.open(__filename, 'r', common.mustCall(function(err, fd) {
18-
if (err) {
19-
throw err;
20-
}
18+
fs.open(__filename, 'r', common.mustCall((err) => {
19+
assert.ifError(err);
2120
}));
2221

23-
fs.open(__filename, 'rs', common.mustCall(function(err, fd) {
24-
if (err) {
25-
throw err;
26-
}
22+
fs.open(__filename, 'rs', common.mustCall((err) => {
23+
assert.ifError(err);
2724
}));

0 commit comments

Comments
 (0)