diff --git a/test/parallel/test-stream-big-packet.js b/test/parallel/test-stream-big-packet.js index 8dc910022d2821..8e5af3ea4ba342 100644 --- a/test/parallel/test-stream-big-packet.js +++ b/test/parallel/test-stream-big-packet.js @@ -1,10 +1,10 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var util = require('util'); -var stream = require('stream'); +const assert = require('assert'); +const util = require('util'); +const stream = require('stream'); -var passed = false; +let passed = false; function PassThrough() { stream.Transform.call(this); @@ -27,15 +27,15 @@ TestStream.prototype._transform = function(chunk, encoding, done) { done(); }; -var s1 = new PassThrough(); -var s2 = new PassThrough(); -var s3 = new TestStream(); +const s1 = new PassThrough(); +const s2 = new PassThrough(); +const s3 = new TestStream(); s1.pipe(s3); // Don't let s2 auto close which may close s3 s2.pipe(s3, {end: false}); // We must write a buffer larger than highWaterMark -var big = Buffer.alloc(s1._writableState.highWaterMark + 1, 'x'); +const big = Buffer.alloc(s1._writableState.highWaterMark + 1, 'x'); // Since big is larger than highWaterMark, it will be buffered internally. assert(!s1.write(big)); diff --git a/test/parallel/test-stream-big-push.js b/test/parallel/test-stream-big-push.js index b46665efc94ff5..d9b79ebafc1d08 100644 --- a/test/parallel/test-stream-big-push.js +++ b/test/parallel/test-stream-big-push.js @@ -1,17 +1,17 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var stream = require('stream'); -var str = 'asdfasdfasdfasdfasdf'; +const assert = require('assert'); +const stream = require('stream'); +const str = 'asdfasdfasdfasdfasdf'; -var r = new stream.Readable({ +const r = new stream.Readable({ highWaterMark: 5, encoding: 'utf8' }); -var reads = 0; -var eofed = false; -var ended = false; +let reads = 0; +let eofed = false; +let ended = false; r._read = function(n) { if (reads === 0) { @@ -21,7 +21,7 @@ r._read = function(n) { reads++; } else if (reads === 1) { var ret = r.push(str); - assert.equal(ret, false); + assert.strictEqual(ret, false); reads++; } else { assert(!eofed); @@ -40,9 +40,9 @@ var ret = r.push(str); // should be false. > hwm assert(!ret); var chunk = r.read(); -assert.equal(chunk, str); +assert.strictEqual(chunk, str); chunk = r.read(); -assert.equal(chunk, null); +assert.strictEqual(chunk, null); r.once('readable', function() { // this time, we'll get *all* the remaining data, because @@ -50,15 +50,15 @@ r.once('readable', function() { // us below the hwm, and so it triggered a _read() again, // which synchronously added more, which we then return. chunk = r.read(); - assert.equal(chunk, str + str); + assert.strictEqual(chunk, str + str); chunk = r.read(); - assert.equal(chunk, null); + assert.strictEqual(chunk, null); }); process.on('exit', function() { assert(eofed); assert(ended); - assert.equal(reads, 2); + assert.strictEqual(reads, 2); console.log('ok'); }); diff --git a/test/parallel/test-stream-duplex.js b/test/parallel/test-stream-duplex.js index 200de24877bf79..3760960ac9346c 100644 --- a/test/parallel/test-stream-duplex.js +++ b/test/parallel/test-stream-duplex.js @@ -1,16 +1,15 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); +const Duplex = require('stream').Transform; -var Duplex = require('stream').Transform; - -var stream = new Duplex({ objectMode: true }); +const stream = new Duplex({ objectMode: true }); assert(stream._readableState.objectMode); assert(stream._writableState.objectMode); -var written; -var read; +let written; +let read; stream._write = function(obj, _, cb) { written = obj; diff --git a/test/parallel/test-stream-end-paused.js b/test/parallel/test-stream-end-paused.js index 96a9c4ee132513..3c46d49ea65d65 100644 --- a/test/parallel/test-stream-end-paused.js +++ b/test/parallel/test-stream-end-paused.js @@ -1,12 +1,12 @@ 'use strict'; const common = require('../common'); -var assert = require('assert'); +const assert = require('assert'); // Make sure we don't miss the end event for paused 0-length streams -var Readable = require('stream').Readable; -var stream = new Readable(); -var calledRead = false; +const Readable = require('stream').Readable; +const stream = new Readable(); +let calledRead = false; stream._read = function() { assert(!calledRead); calledRead = true; diff --git a/test/parallel/test-stream-ispaused.js b/test/parallel/test-stream-ispaused.js index 38f8da3fd512e4..f25e717b2b7be9 100644 --- a/test/parallel/test-stream-ispaused.js +++ b/test/parallel/test-stream-ispaused.js @@ -1,10 +1,9 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); +const stream = require('stream'); -var stream = require('stream'); - -var readable = new stream.Readable(); +const readable = new stream.Readable(); // _read is a noop, here. readable._read = Function(); diff --git a/test/parallel/test-stream-pipe-after-end.js b/test/parallel/test-stream-pipe-after-end.js index 258c9330a96018..1193db21835cb1 100644 --- a/test/parallel/test-stream-pipe-after-end.js +++ b/test/parallel/test-stream-pipe-after-end.js @@ -1,10 +1,9 @@ 'use strict'; require('../common'); -var assert = require('assert'); - -var Readable = require('_stream_readable'); -var Writable = require('_stream_writable'); -var util = require('util'); +const assert = require('assert'); +const Readable = require('_stream_readable'); +const Writable = require('_stream_writable'); +const util = require('util'); util.inherits(TestReadable, Readable); function TestReadable(opt) { @@ -35,11 +34,11 @@ TestWritable.prototype._write = function(chunk, encoding, cb) { }; // this one should not emit 'end' until we read() from it later. -var ender = new TestReadable(); -var enderEnded = false; +const ender = new TestReadable(); +let enderEnded = false; // what happens when you pipe() a Readable that's already ended? -var piper = new TestReadable(); +const piper = new TestReadable(); // pushes EOF null, and length=0, so this will trigger 'end' piper.read(); @@ -48,11 +47,11 @@ setTimeout(function() { enderEnded = true; }); assert(!enderEnded); - var c = ender.read(); + const c = ender.read(); assert.equal(c, null); - var w = new TestWritable(); - var writableFinished = false; + const w = new TestWritable(); + let writableFinished = false; w.on('finish', function() { writableFinished = true; }); diff --git a/test/parallel/test-stream-pipe-cleanup.js b/test/parallel/test-stream-pipe-cleanup.js index 251695c9f723ab..b28b99b772af26 100644 --- a/test/parallel/test-stream-pipe-cleanup.js +++ b/test/parallel/test-stream-pipe-cleanup.js @@ -1,11 +1,10 @@ 'use strict'; // This test asserts that Stream.prototype.pipe does not leave listeners // hanging on the source or dest. - require('../common'); -var stream = require('stream'); -var assert = require('assert'); -var util = require('util'); +const stream = require('stream'); +const assert = require('assert'); +const util = require('util'); function Writable() { this.writable = true; @@ -33,20 +32,20 @@ function Duplex() { } util.inherits(Duplex, Writable); -var i = 0; -var limit = 100; +let i = 0; +const limit = 100; -var w = new Writable(); +let w = new Writable(); -var r; +let r; for (i = 0; i < limit; i++) { r = new Readable(); r.pipe(w); r.emit('end'); } -assert.equal(0, r.listeners('end').length); -assert.equal(limit, w.endCalls); +assert.strictEqual(0, r.listeners('end').length); +assert.strictEqual(limit, w.endCalls); w.endCalls = 0; @@ -55,8 +54,8 @@ for (i = 0; i < limit; i++) { r.pipe(w); r.emit('close'); } -assert.equal(0, r.listeners('close').length); -assert.equal(limit, w.endCalls); +assert.strictEqual(0, r.listeners('close').length); +assert.strictEqual(limit, w.endCalls); w.endCalls = 0; @@ -67,36 +66,37 @@ for (i = 0; i < limit; i++) { r.pipe(w); w.emit('close'); } -assert.equal(0, w.listeners('close').length); +assert.strictEqual(0, w.listeners('close').length); r = new Readable(); w = new Writable(); -var d = new Duplex(); +const d = new Duplex(); r.pipe(d); // pipeline A d.pipe(w); // pipeline B -assert.equal(r.listeners('end').length, 2); // A.onend, A.cleanup -assert.equal(r.listeners('close').length, 2); // A.onclose, A.cleanup -assert.equal(d.listeners('end').length, 2); // B.onend, B.cleanup -assert.equal(d.listeners('close').length, 3); // A.cleanup, B.onclose, B.cleanup -assert.equal(w.listeners('end').length, 0); -assert.equal(w.listeners('close').length, 1); // B.cleanup +assert.strictEqual(r.listeners('end').length, 2); // A.onend, A.cleanup +assert.strictEqual(r.listeners('close').length, 2); // A.onclose, A.cleanup +assert.strictEqual(d.listeners('end').length, 2); // B.onend, B.cleanup +// A.cleanup, B.onclose, B.cleanup +assert.strictEqual(d.listeners('close').length, 3); +assert.strictEqual(w.listeners('end').length, 0); +assert.strictEqual(w.listeners('close').length, 1); // B.cleanup r.emit('end'); -assert.equal(d.endCalls, 1); -assert.equal(w.endCalls, 0); -assert.equal(r.listeners('end').length, 0); -assert.equal(r.listeners('close').length, 0); -assert.equal(d.listeners('end').length, 2); // B.onend, B.cleanup -assert.equal(d.listeners('close').length, 2); // B.onclose, B.cleanup -assert.equal(w.listeners('end').length, 0); -assert.equal(w.listeners('close').length, 1); // B.cleanup +assert.strictEqual(d.endCalls, 1); +assert.strictEqual(w.endCalls, 0); +assert.strictEqual(r.listeners('end').length, 0); +assert.strictEqual(r.listeners('close').length, 0); +assert.strictEqual(d.listeners('end').length, 2); // B.onend, B.cleanup +assert.strictEqual(d.listeners('close').length, 2); // B.onclose, B.cleanup +assert.strictEqual(w.listeners('end').length, 0); +assert.strictEqual(w.listeners('close').length, 1); // B.cleanup d.emit('end'); -assert.equal(d.endCalls, 1); -assert.equal(w.endCalls, 1); -assert.equal(r.listeners('end').length, 0); -assert.equal(r.listeners('close').length, 0); -assert.equal(d.listeners('end').length, 0); -assert.equal(d.listeners('close').length, 0); -assert.equal(w.listeners('end').length, 0); -assert.equal(w.listeners('close').length, 0); +assert.strictEqual(d.endCalls, 1); +assert.strictEqual(w.endCalls, 1); +assert.strictEqual(r.listeners('end').length, 0); +assert.strictEqual(r.listeners('close').length, 0); +assert.strictEqual(d.listeners('end').length, 0); +assert.strictEqual(d.listeners('close').length, 0); +assert.strictEqual(w.listeners('end').length, 0); +assert.strictEqual(w.listeners('close').length, 0);