mirror of https://github.com/lukechilds/node.git
Browse Source
* 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: https://github.com/nodejs/node/pull/10312 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Italo A. Casas <me@italoacasas.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>v6
Adrian Estrada
8 years ago
committed by
Italo A. Casas
1 changed files with 10 additions and 13 deletions
@ -1,27 +1,24 @@ |
|||||
'use strict'; |
'use strict'; |
||||
const common = require('../common'); |
const common = require('../common'); |
||||
var assert = require('assert'); |
const assert = require('assert'); |
||||
var fs = require('fs'); |
const fs = require('fs'); |
||||
|
|
||||
|
let caughtException = false; |
||||
|
|
||||
var caughtException = false; |
|
||||
try { |
try { |
||||
// should throw ENOENT, not EBADF
|
// should throw ENOENT, not EBADF
|
||||
// see https://github.com/joyent/node/pull/1228
|
// see https://github.com/joyent/node/pull/1228
|
||||
fs.openSync('/path/to/file/that/does/not/exist', 'r'); |
fs.openSync('/path/to/file/that/does/not/exist', 'r'); |
||||
} catch (e) { |
} catch (e) { |
||||
assert.equal(e.code, 'ENOENT'); |
assert.strictEqual(e.code, 'ENOENT'); |
||||
caughtException = true; |
caughtException = true; |
||||
} |
} |
||||
assert.ok(caughtException); |
assert.strictEqual(caughtException, true); |
||||
|
|
||||
fs.open(__filename, 'r', common.mustCall(function(err, fd) { |
fs.open(__filename, 'r', common.mustCall((err) => { |
||||
if (err) { |
assert.ifError(err); |
||||
throw err; |
|
||||
} |
|
||||
})); |
})); |
||||
|
|
||||
fs.open(__filename, 'rs', common.mustCall(function(err, fd) { |
fs.open(__filename, 'rs', common.mustCall((err) => { |
||||
if (err) { |
assert.ifError(err); |
||||
throw err; |
|
||||
} |
|
||||
})); |
})); |
||||
|
Loading…
Reference in new issue