From 0fa35bc9c8611e8e9dca6dc7f28cd63fde89c054 Mon Sep 17 00:00:00 2001 From: Erez Weiss Date: Sat, 3 Dec 2016 20:32:28 +0200 Subject: [PATCH] test: implemented es6 conventions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit implemented arrow functions and changed var to const where appropriate. PR-URL: https://github.com/nodejs/node/pull/9669 Reviewed-By: Michaƫl Zasso Reviewed-By: Colin Ihrig Reviewed-By: James M Snell --- test/parallel/test-fs-read-stream-err.js | 41 ++++++++++++------------ 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/test/parallel/test-fs-read-stream-err.js b/test/parallel/test-fs-read-stream-err.js index 1bc2b6f0b0239c..32e9b02455e20a 100644 --- a/test/parallel/test-fs-read-stream-err.js +++ b/test/parallel/test-fs-read-stream-err.js @@ -1,43 +1,42 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var fs = require('fs'); +const common = require('../common'); +const assert = require('assert'); +const fs = require('fs'); -var stream = fs.createReadStream(__filename, { +const stream = fs.createReadStream(__filename, { bufferSize: 64 }); -var err = new Error('BAM'); +const err = new Error('BAM'); -stream.on('error', common.mustCall(function errorHandler(err_) { - console.error('error event'); - process.nextTick(function() { - assert.equal(stream.fd, null); - assert.equal(err_, err); - }); +stream.on('error', common.mustCall((err_) => { + process.nextTick(common.mustCall(() => { + assert.strictEqual(stream.fd, null); + assert.strictEqual(err_, err); + })); })); -fs.close = common.mustCall(function(fd_, cb) { - assert.equal(fd_, stream.fd); +fs.close = common.mustCall((fd_, cb) => { + assert.strictEqual(fd_, stream.fd); process.nextTick(cb); }); -var read = fs.read; +const read = fs.read; fs.read = function() { // first time is ok. read.apply(fs, arguments); // then it breaks - fs.read = function() { - var cb = arguments[arguments.length - 1]; - process.nextTick(function() { + fs.read = common.mustCall(function() { + const cb = arguments[arguments.length - 1]; + process.nextTick(() => { cb(err); }); // and should not be called again! - fs.read = function() { + fs.read = () => { throw new Error('BOOM!'); }; - }; + }); }; -stream.on('data', function(buf) { - stream.on('data', common.fail); // no more 'data' events should follow +stream.on('data', (buf) => { + stream.on('data', () => common.fail("no more 'data' events should follow")); });