Skip to content

Commit

Permalink
test: use mustNotCall() in test-stream2-objects
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Trott authored and MylesBorins committed Aug 16, 2017
1 parent b793fc6 commit 3808e37
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions test/parallel/test-stream2-objects.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';
require('../common');
const common = require('../common');
const Readable = require('_stream_readable');
const Writable = require('_stream_writable');
const assert = require('assert');
Expand Down Expand Up @@ -54,7 +54,7 @@ function toArray(callback) {

function fromArray(list) {
const r = new Readable({ objectMode: true });
r._read = noop;
r._read = common.mustNotCall();
list.forEach(function(chunk) {
r.push(chunk);
});
Expand All @@ -63,8 +63,6 @@ function fromArray(list) {
return r;
}

function noop() {}

test('can read objects from stream', function(t) {
const r = fromArray([{ one: '1'}, { two: '2' }]);

Expand Down Expand Up @@ -144,7 +142,7 @@ test('can read strings as objects', function(t) {
const r = new Readable({
objectMode: true
});
r._read = noop;
r._read = common.mustNotCall();
const list = ['one', 'two', 'three'];
list.forEach(function(str) {
r.push(str);
Expand All @@ -162,7 +160,7 @@ test('read(0) for object streams', function(t) {
const r = new Readable({
objectMode: true
});
r._read = noop;
r._read = common.mustNotCall();

r.push('foobar');
r.push(null);
Expand All @@ -178,7 +176,7 @@ test('falsey values', function(t) {
const r = new Readable({
objectMode: true
});
r._read = noop;
r._read = common.mustNotCall();

r.push(false);
r.push(0);
Expand Down Expand Up @@ -229,7 +227,7 @@ test('high watermark push', function(t) {
highWaterMark: 6,
objectMode: true
});
r._read = function(n) {};
r._read = common.mustNotCall();
for (let i = 0; i < 6; i++) {
const bool = r.push(i);
assert.strictEqual(bool, i !== 5);
Expand Down

0 comments on commit 3808e37

Please sign in to comment.