Skip to content

Commit 7391983

Browse files
ruggertechMylesBorins
authored andcommitted
test: implemented es6 conventions
implemented arrow functions and changed var to const where appropriate. PR-URL: #9669 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 50ce3f9 commit 7391983

File tree

1 file changed

+20
-21
lines changed

1 file changed

+20
-21
lines changed
Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,42 @@
11
'use strict';
2-
varcommon=require('../common');
3-
varassert=require('assert');
4-
varfs=require('fs');
2+
constcommon=require('../common');
3+
constassert=require('assert');
4+
constfs=require('fs');
55

6-
varstream=fs.createReadStream(__filename,{
6+
conststream=fs.createReadStream(__filename,{
77
bufferSize: 64
88
});
9-
varerr=newError('BAM');
9+
consterr=newError('BAM');
1010

11-
stream.on('error',common.mustCall(functionerrorHandler(err_){
12-
console.error('error event');
13-
process.nextTick(function(){
14-
assert.equal(stream.fd,null);
15-
assert.equal(err_,err);
16-
});
11+
stream.on('error',common.mustCall((err_)=>{
12+
process.nextTick(common.mustCall(()=>{
13+
assert.strictEqual(stream.fd,null);
14+
assert.strictEqual(err_,err);
15+
}));
1716
}));
1817

19-
fs.close=common.mustCall(function(fd_,cb){
20-
assert.equal(fd_,stream.fd);
18+
fs.close=common.mustCall((fd_,cb)=>{
19+
assert.strictEqual(fd_,stream.fd);
2120
process.nextTick(cb);
2221
});
2322

24-
varread=fs.read;
23+
constread=fs.read;
2524
fs.read=function(){
2625
// first time is ok.
2726
read.apply(fs,arguments);
2827
// then it breaks
29-
fs.read=function(){
30-
varcb=arguments[arguments.length-1];
31-
process.nextTick(function(){
28+
fs.read=common.mustCall(function(){
29+
constcb=arguments[arguments.length-1];
30+
process.nextTick(()=>{
3231
cb(err);
3332
});
3433
// and should not be called again!
35-
fs.read=function(){
34+
fs.read=()=>{
3635
thrownewError('BOOM!');
3736
};
38-
};
37+
});
3938
};
4039

41-
stream.on('data',function(buf){
42-
stream.on('data',common.fail);// no more 'data' events should follow
40+
stream.on('data',(buf)=>{
41+
stream.on('data',()=>common.fail("no more 'data' events should follow"));
4342
});

0 commit comments

Comments
(0)