From 4510c72cf344dab1cbe0e83913fea358a93c2809 Mon Sep 17 00:00:00 2001 From: Adrian Estrada Date: Sat, 17 Dec 2016 18:10:57 -0500 Subject: [PATCH] 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: https://github.com/nodejs/node/pull/10312 Reviewed-By: Colin Ihrig Reviewed-By: Italo A. Casas Reviewed-By: Luigi Pinca Reviewed-By: Santiago Gimeno --- test/parallel/test-fs-open.js | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/test/parallel/test-fs-open.js b/test/parallel/test-fs-open.js index a5a9bbf2577fca..d2d24b1e07ab75 100644 --- a/test/parallel/test-fs-open.js +++ b/test/parallel/test-fs-open.js @@ -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); }));