diff options
author | adelmann <adelmann@adobe.com> | 2016-12-01 11:39:38 -0600 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2016-12-03 20:03:32 -0800 |
commit | 8a959107c0da7fe61ba0c54edc931a4a96144526 (patch) | |
tree | a7b5d80e7b48b38313b31b8923108c309db5909c /test/parallel/test-fs-write-file.js | |
parent | 451f88e4283eacf128f1937af291766a21752207 (diff) | |
download | android-node-v8-8a959107c0da7fe61ba0c54edc931a4a96144526.tar.gz android-node-v8-8a959107c0da7fe61ba0c54edc931a4a96144526.tar.bz2 android-node-v8-8a959107c0da7fe61ba0c54edc931a4a96144526.zip |
test: refactor test-fs-write-file
Replaced all error checks with assert.ifError(e).
PR-URL: https://github.com/nodejs/node/pull/10030
Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'test/parallel/test-fs-write-file.js')
-rw-r--r-- | test/parallel/test-fs-write-file.js | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/test/parallel/test-fs-write-file.js b/test/parallel/test-fs-write-file.js index c62993b8da..acc69764fe 100644 --- a/test/parallel/test-fs-write-file.js +++ b/test/parallel/test-fs-write-file.js @@ -18,10 +18,10 @@ const s = '南越国是前203年至前111年存在于岭南地区的一个国家 '它的建立保证了秦末乱世岭南地区社会秩序的稳定,有效的改善了岭南地区落后的政治、##济现状。\n'; fs.writeFile(filename, s, common.mustCall(function(e) { - if (e) throw e; + assert.ifError(e); fs.readFile(filename, common.mustCall(function(e, buffer) { - if (e) throw e; + assert.ifError(e); assert.strictEqual(Buffer.byteLength(s), buffer.length); })); })); @@ -31,10 +31,10 @@ const filename2 = join(common.tmpDir, 'test2.txt'); const buf = Buffer.from(s, 'utf8'); fs.writeFile(filename2, buf, common.mustCall(function(e) { - if (e) throw e; + assert.ifError(e); fs.readFile(filename2, common.mustCall(function(e, buffer) { - if (e) throw e; + assert.ifError(e); assert.strictEqual(buf.length, buffer.length); })); @@ -45,7 +45,7 @@ const filename3 = join(common.tmpDir, 'test3.txt'); const m = 0o600; fs.writeFile(filename3, n, { mode: m }, common.mustCall(function(e) { - if (e) throw e; + assert.ifError(e); // windows permissions aren't unix if (!common.isWindows) { @@ -54,7 +54,7 @@ fs.writeFile(filename3, n, { mode: m }, common.mustCall(function(e) { } fs.readFile(filename3, common.mustCall(function(e, buffer) { - if (e) throw e; + assert.ifError(e); assert.strictEqual(Buffer.byteLength('' + n), buffer.length); })); @@ -64,16 +64,16 @@ fs.writeFile(filename3, n, { mode: m }, common.mustCall(function(e) { const filename4 = join(common.tmpDir, 'test4.txt'); fs.open(filename4, 'w+', common.mustCall(function(e, fd) { - if (e) throw e; + assert.ifError(e); fs.writeFile(fd, s, common.mustCall(function(e) { - if (e) throw e; + assert.ifError(e); fs.close(fd, common.mustCall(function(e) { - if (e) throw e; + assert.ifError(e); fs.readFile(filename4, common.mustCall(function(e, buffer) { - if (e) throw e; + assert.ifError(e); assert.strictEqual(Buffer.byteLength(s), buffer.length); })); |