-
Notifications
You must be signed in to change notification settings - Fork 30.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
1 changed file
with
10 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,24 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
var assert = require('assert'); | ||
var fs = require('fs'); | ||
const assert = require('assert'); | ||
const fs = require('fs'); | ||
|
||
let caughtException = false; | ||
|
||
var caughtException = false; | ||
try { | ||
// should throw ENOENT, not EBADF | ||
// see https://github.com/joyent/node/pull/1228 | ||
fs.openSync('/path/to/file/that/does/not/exist', 'r'); | ||
} catch (e) { | ||
assert.equal(e.code, 'ENOENT'); | ||
assert.strictEqual(e.code, 'ENOENT'); | ||
caughtException = true; | ||
} | ||
assert.ok(caughtException); | ||
assert.strictEqual(caughtException, true); | ||
|
||
fs.open(__filename, 'r', common.mustCall(function(err, fd) { | ||
if (err) { | ||
throw err; | ||
} | ||
fs.open(__filename, 'r', common.mustCall((err) => { | ||
assert.ifError(err); | ||
})); | ||
|
||
fs.open(__filename, 'rs', common.mustCall(function(err, fd) { | ||
if (err) { | ||
throw err; | ||
} | ||
fs.open(__filename, 'rs', common.mustCall((err) => { | ||
assert.ifError(err); | ||
})); |