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 <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>
This commit is contained in:
parent
bb91879f31
commit
64ded9f9bc
@ -76,7 +76,7 @@ function toArray(callback) {
|
|||||||
|
|
||||||
function fromArray(list) {
|
function fromArray(list) {
|
||||||
const r = new Readable({ objectMode: true });
|
const r = new Readable({ objectMode: true });
|
||||||
r._read = common.noop;
|
r._read = common.mustNotCall();
|
||||||
list.forEach(function(chunk) {
|
list.forEach(function(chunk) {
|
||||||
r.push(chunk);
|
r.push(chunk);
|
||||||
});
|
});
|
||||||
@ -164,7 +164,7 @@ test('can read strings as objects', function(t) {
|
|||||||
const r = new Readable({
|
const r = new Readable({
|
||||||
objectMode: true
|
objectMode: true
|
||||||
});
|
});
|
||||||
r._read = common.noop;
|
r._read = common.mustNotCall();
|
||||||
const list = ['one', 'two', 'three'];
|
const list = ['one', 'two', 'three'];
|
||||||
list.forEach(function(str) {
|
list.forEach(function(str) {
|
||||||
r.push(str);
|
r.push(str);
|
||||||
@ -182,7 +182,7 @@ test('read(0) for object streams', function(t) {
|
|||||||
const r = new Readable({
|
const r = new Readable({
|
||||||
objectMode: true
|
objectMode: true
|
||||||
});
|
});
|
||||||
r._read = common.noop;
|
r._read = common.mustNotCall();
|
||||||
|
|
||||||
r.push('foobar');
|
r.push('foobar');
|
||||||
r.push(null);
|
r.push(null);
|
||||||
@ -198,7 +198,7 @@ test('falsey values', function(t) {
|
|||||||
const r = new Readable({
|
const r = new Readable({
|
||||||
objectMode: true
|
objectMode: true
|
||||||
});
|
});
|
||||||
r._read = common.noop;
|
r._read = common.mustNotCall();
|
||||||
|
|
||||||
r.push(false);
|
r.push(false);
|
||||||
r.push(0);
|
r.push(0);
|
||||||
@ -249,7 +249,7 @@ test('high watermark push', function(t) {
|
|||||||
highWaterMark: 6,
|
highWaterMark: 6,
|
||||||
objectMode: true
|
objectMode: true
|
||||||
});
|
});
|
||||||
r._read = common.noop;
|
r._read = common.mustNotCall();
|
||||||
for (let i = 0; i < 6; i++) {
|
for (let i = 0; i < 6; i++) {
|
||||||
const bool = r.push(i);
|
const bool = r.push(i);
|
||||||
assert.strictEqual(bool, i !== 5);
|
assert.strictEqual(bool, i !== 5);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user