summaryrefslogtreecommitdiff
path: root/test/parallel/test-fs-open.js
diff options
context:
space:
mode:
authorAdrian Estrada <edsadr@gmail.com>2016-12-17 18:10:57 -0500
committerItalo A. Casas <me@italoacasas.com>2016-12-19 20:03:17 -0500
commit15c71f6c66a8515597f9a4886b35510950c474ef (patch)
tree0944b9e0d3eea44c89e5d2af0d56cf8de6544d89 /test/parallel/test-fs-open.js
parenta308a2fae4386aa71a062f21ee01495611b20606 (diff)
downloadandroid-node-v8-15c71f6c66a8515597f9a4886b35510950c474ef.tar.gz
android-node-v8-15c71f6c66a8515597f9a4886b35510950c474ef.tar.bz2
android-node-v8-15c71f6c66a8515597f9a4886b35510950c474ef.zip
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 <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>
Diffstat (limited to 'test/parallel/test-fs-open.js')
-rw-r--r--test/parallel/test-fs-open.js23
1 files changed, 10 insertions, 13 deletions
diff --git a/test/parallel/test-fs-open.js b/test/parallel/test-fs-open.js
index a5a9bbf257..d2d24b1e07 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);
}));