Browse Source

test: implemented es6 conventions

implemented arrow functions and changed var to const where
appropriate.

PR-URL: https://github.com/nodejs/node/pull/9669
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
v6.x
Erez Weiss 8 years ago
committed by Anna Henningsen
parent
commit
dd4f9195f1
No known key found for this signature in database GPG Key ID: D8B9F5AEAE84E4CF
  1. 41
      test/parallel/test-fs-read-stream-err.js

41
test/parallel/test-fs-read-stream-err.js

@ -1,43 +1,42 @@
'use strict'; 'use strict';
var common = require('../common'); const common = require('../common');
var assert = require('assert'); const assert = require('assert');
var fs = require('fs'); const fs = require('fs');
var stream = fs.createReadStream(__filename, { const stream = fs.createReadStream(__filename, {
bufferSize: 64 bufferSize: 64
}); });
var err = new Error('BAM'); const err = new Error('BAM');
stream.on('error', common.mustCall(function errorHandler(err_) { stream.on('error', common.mustCall((err_) => {
console.error('error event'); process.nextTick(common.mustCall(() => {
process.nextTick(function() { assert.strictEqual(stream.fd, null);
assert.equal(stream.fd, null); assert.strictEqual(err_, err);
assert.equal(err_, err); }));
});
})); }));
fs.close = common.mustCall(function(fd_, cb) { fs.close = common.mustCall((fd_, cb) => {
assert.equal(fd_, stream.fd); assert.strictEqual(fd_, stream.fd);
process.nextTick(cb); process.nextTick(cb);
}); });
var read = fs.read; const read = fs.read;
fs.read = function() { fs.read = function() {
// first time is ok. // first time is ok.
read.apply(fs, arguments); read.apply(fs, arguments);
// then it breaks // then it breaks
fs.read = function() { fs.read = common.mustCall(function() {
var cb = arguments[arguments.length - 1]; const cb = arguments[arguments.length - 1];
process.nextTick(function() { process.nextTick(() => {
cb(err); cb(err);
}); });
// and should not be called again! // and should not be called again!
fs.read = function() { fs.read = () => {
throw new Error('BOOM!'); throw new Error('BOOM!');
}; };
}; });
}; };
stream.on('data', function(buf) { stream.on('data', (buf) => {
stream.on('data', common.fail); // no more 'data' events should follow stream.on('data', () => common.fail("no more 'data' events should follow"));
}); });

Loading…
Cancel
Save