From 3808e3701ccd7edd2408d94b13518681f77a2ee0 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Fri, 26 May 2017 14:54:51 -0700 Subject: [PATCH] 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: https://github.com/nodejs/node/pull/13249 Reviewed-By: Refael Ackermann Reviewed-By: Luigi Pinca Reviewed-By: Benjamin Gruenbaum Reviewed-By: Colin Ihrig Reviewed-By: James M Snell --- test/parallel/test-stream2-objects.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/test/parallel/test-stream2-objects.js b/test/parallel/test-stream2-objects.js index cab838fbfc..cea3a48451 100644 --- a/test/parallel/test-stream2-objects.js +++ b/test/parallel/test-stream2-objects.js @@ -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'); @@ -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); }); @@ -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' }]); @@ -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); @@ -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); @@ -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); @@ -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);