test: cleanup stream tests · nodejs/node@735119c · GitHub
Skip to content

Commit 735119c

Browse files
Italo A. CasasMylesBorins
authored andcommitted
test: cleanup stream tests
const and let instead var assert.strictEqual instead assert.equal PR-URL: #8668 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 31434a1 commit 735119c

7 files changed

Lines changed: 79 additions & 82 deletions

test/parallel/test-stream-big-packet.js

Lines changed: 8 additions & 8 deletions
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
'use strict';
22
require('../common');
3-
var assert = require('assert');
4-
var stream = require('stream');
5-
var str = 'asdfasdfasdfasdfasdf';
3+
const assert = require('assert');
4+
const stream = require('stream');
5+
const str = 'asdfasdfasdfasdfasdf';
66

7-
var r = new stream.Readable({
7+
const r = new stream.Readable({
88
highWaterMark: 5,
99
encoding: 'utf8'
1010
});
1111

12-
var reads = 0;
13-
var eofed = false;
14-
var ended = false;
12+
let reads = 0;
13+
let eofed = false;
14+
let ended = false;
1515

1616
r._read = function(n) {
1717
if (reads === 0) {
@@ -21,7 +21,7 @@ r._read = function(n) {
2121
reads++;
2222
} else if (reads === 1) {
2323
var ret = r.push(str);
24-
assert.equal(ret, false);
24+
assert.strictEqual(ret, false);
2525
reads++;
2626
} else {
2727
assert(!eofed);
@@ -40,25 +40,25 @@ var ret = r.push(str);
4040
// should be false. > hwm
4141
assert(!ret);
4242
var chunk = r.read();
43-
assert.equal(chunk, str);
43+
assert.strictEqual(chunk, str);
4444
chunk = r.read();
45-
assert.equal(chunk, null);
45+
assert.strictEqual(chunk, null);
4646

4747
r.once('readable', function() {
4848
// this time, we'll get *all* the remaining data, because
4949
// it's been added synchronously, as the read WOULD take
5050
// us below the hwm, and so it triggered a _read() again,
5151
// which synchronously added more, which we then return.
5252
chunk = r.read();
53-
assert.equal(chunk, str + str);
53+
assert.strictEqual(chunk, str + str);
5454

5555
chunk = r.read();
56-
assert.equal(chunk, null);
56+
assert.strictEqual(chunk, null);
5757
});
5858

5959
process.on('exit', function() {
6060
assert(eofed);
6161
assert(ended);
62-
assert.equal(reads, 2);
62+
assert.strictEqual(reads, 2);
6363
console.log('ok');
6464
});

test/parallel/test-stream-duplex.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
'use strict';
22
require('../common');
3-
var assert = require('assert');
3+
const assert = require('assert');
4+
const Duplex = require('stream').Transform;
45

5-
var Duplex = require('stream').Transform;
6-
7-
var stream = new Duplex({ objectMode: true });
6+
const stream = new Duplex({ objectMode: true });
87

98
assert(stream._readableState.objectMode);
109
assert(stream._writableState.objectMode);
1110

12-
var written;
13-
var read;
11+
let written;
12+
let read;
1413

1514
stream._write = function(obj, _, cb) {
1615
written = obj;

test/parallel/test-stream-end-paused.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
'use strict';
22
const common = require('../common');
3-
var assert = require('assert');
3+
const assert = require('assert');
44

55
// Make sure we don't miss the end event for paused 0-length streams
66

7-
var Readable = require('stream').Readable;
8-
var stream = new Readable();
9-
var calledRead = false;
7+
const Readable = require('stream').Readable;
8+
const stream = new Readable();
9+
let calledRead = false;
1010
stream._read = function() {
1111
assert(!calledRead);
1212
calledRead = true;

test/parallel/test-stream-ispaused.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
'use strict';
22
require('../common');
3-
var assert = require('assert');
3+
const assert = require('assert');
4+
const stream = require('stream');
45

5-
var stream = require('stream');
6-
7-
var readable = new stream.Readable();
6+
const readable = new stream.Readable();
87

98
// _read is a noop, here.
109
readable._read = Function();

test/parallel/test-stream-pipe-after-end.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
'use strict';
22
require('../common');
3-
var assert = require('assert');
4-
5-
var Readable = require('_stream_readable');
6-
var Writable = require('_stream_writable');
7-
var util = require('util');
3+
const assert = require('assert');
4+
const Readable = require('_stream_readable');
5+
const Writable = require('_stream_writable');
6+
const util = require('util');
87

98
util.inherits(TestReadable, Readable);
109
function TestReadable(opt) {
@@ -35,11 +34,11 @@ TestWritable.prototype._write = function(chunk, encoding, cb) {
3534
};
3635

3736
// this one should not emit 'end' until we read() from it later.
38-
var ender = new TestReadable();
39-
var enderEnded = false;
37+
const ender = new TestReadable();
38+
let enderEnded = false;
4039

4140
// what happens when you pipe() a Readable that's already ended?
42-
var piper = new TestReadable();
41+
const piper = new TestReadable();
4342
// pushes EOF null, and length=0, so this will trigger 'end'
4443
piper.read();
4544

@@ -48,11 +47,11 @@ setTimeout(function() {
4847
enderEnded = true;
4948
});
5049
assert(!enderEnded);
51-
var c = ender.read();
50+
const c = ender.read();
5251
assert.equal(c, null);
5352

54-
var w = new TestWritable();
55-
var writableFinished = false;
53+
const w = new TestWritable();
54+
let writableFinished = false;
5655
w.on('finish', function() {
5756
writableFinished = true;
5857
});
Lines changed: 36 additions & 36 deletions

0 commit comments

Comments
 (0)