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 <refack@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent b793fc6 commit 3808e37

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

‎test/parallel/test-stream2-objects.js‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use strict';
2-
require('../common');
2+
constcommon=require('../common');
33
constReadable=require('_stream_readable');
44
constWritable=require('_stream_writable');
55
constassert=require('assert');
@@ -54,7 +54,7 @@ function toArray(callback) {
5454

5555
functionfromArray(list){
5656
constr=newReadable({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
returnr;
6464
}
6565

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

@@ -144,7 +142,7 @@ test('can read strings as objects', function(t) {
144142
constr=newReadable({
145143
objectMode: true
146144
});
147-
r._read=noop;
145+
r._read=common.mustNotCall();
148146
constlist=['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
constr=newReadable({
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
constr=newReadable({
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(leti=0;i<6;i++){
234232
constbool=r.push(i);
235233
assert.strictEqual(bool,i!==5);

0 commit comments

Comments
 (0)