Skip to content

Commit 3808e37

Browse files
TrottMylesBorins
authored andcommitted
test: use mustNotCall() in test-stream2-objects
Use `common.mustNotCall()` in test-stream2-objects.js to confirm that noop function is never invoked. PR-URL: #13249 Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent b793fc6 commit 3808e37

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

test/parallel/test-stream2-objects.js

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use strict';
2-
require('../common');
2+
const common = require('../common');
33
const Readable = require('_stream_readable');
44
const Writable = require('_stream_writable');
55
const assert = require('assert');
@@ -54,7 +54,7 @@ function toArray(callback) {
5454

5555
function fromArray(list) {
5656
const r = new Readable({ objectMode: true });
57-
r._read = noop;
57+
r._read = common.mustNotCall();
5858
list.forEach(function(chunk) {
5959
r.push(chunk);
6060
});
@@ -63,8 +63,6 @@ function fromArray(list) {
6363
return r;
6464
}
6565

66-
function noop() {}
67-
6866
test('can read objects from stream', function(t) {
6967
const r = fromArray([{ one: '1'}, { two: '2' }]);
7068

@@ -144,7 +142,7 @@ test('can read strings as objects', function(t) {
144142
const r = new Readable({
145143
objectMode: true
146144
});
147-
r._read = noop;
145+
r._read = common.mustNotCall();
148146
const list = ['one', 'two', 'three'];
149147
list.forEach(function(str) {
150148
r.push(str);
@@ -162,7 +160,7 @@ test('read(0) for object streams', function(t) {
162160
const r = new Readable({
163161
objectMode: true
164162
});
165-
r._read = noop;
163+
r._read = common.mustNotCall();
166164

167165
r.push('foobar');
168166
r.push(null);
@@ -178,7 +176,7 @@ test('falsey values', function(t) {
178176
const r = new Readable({
179177
objectMode: true
180178
});
181-
r._read = noop;
179+
r._read = common.mustNotCall();
182180

183181
r.push(false);
184182
r.push(0);
@@ -229,7 +227,7 @@ test('high watermark push', function(t) {
229227
highWaterMark: 6,
230228
objectMode: true
231229
});
232-
r._read = function(n) {};
230+
r._read = common.mustNotCall();
233231
for (let i = 0; i < 6; i++) {
234232
const bool = r.push(i);
235233
assert.strictEqual(bool, i !== 5);

0 commit comments

Comments
 (0)