test: check noop function invocations
In test/pummel/test-stream2-basic.js, check that noop functions are called the expected number of times. PR-URL: https://github.com/nodejs/node/pull/13146 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
parent
ccd3eadbd7
commit
bbd39c359f
@ -147,7 +147,7 @@ test('a most basic test', function(t) {
|
|||||||
'xxxxxxxxxxxxxxxxxxxxx' ];
|
'xxxxxxxxxxxxxxxxxxxxx' ];
|
||||||
|
|
||||||
r.on('end', function() {
|
r.on('end', function() {
|
||||||
t.same(reads, expect);
|
assert.strict(reads, expect);
|
||||||
t.end();
|
t.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -180,7 +180,7 @@ test('pipe', function(t) {
|
|||||||
const w = new TestWriter();
|
const w = new TestWriter();
|
||||||
|
|
||||||
w.on('end', function(received) {
|
w.on('end', function(received) {
|
||||||
t.same(received, expect);
|
assert.strict(received, expect);
|
||||||
t.end();
|
t.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -226,7 +226,7 @@ test('pipe', function(t) {
|
|||||||
t.equal(ended0, false);
|
t.equal(ended0, false);
|
||||||
ended0 = true;
|
ended0 = true;
|
||||||
ended++;
|
ended++;
|
||||||
t.same(results, expect[0]);
|
assert.strict(results, expect[0]);
|
||||||
});
|
});
|
||||||
|
|
||||||
w[1].on('end', function(results) {
|
w[1].on('end', function(results) {
|
||||||
@ -234,7 +234,7 @@ test('pipe', function(t) {
|
|||||||
ended1 = true;
|
ended1 = true;
|
||||||
ended++;
|
ended++;
|
||||||
t.equal(ended, 2);
|
t.equal(ended, 2);
|
||||||
t.same(results, expect[1]);
|
assert.strict(results, expect[1]);
|
||||||
t.end();
|
t.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -261,11 +261,11 @@ test('multipipe', function(t) {
|
|||||||
|
|
||||||
let c = 2;
|
let c = 2;
|
||||||
w[0].on('end', function(received) {
|
w[0].on('end', function(received) {
|
||||||
t.same(received, expect, 'first');
|
assert.strict(received, expect, 'first');
|
||||||
if (--c === 0) t.end();
|
if (--c === 0) t.end();
|
||||||
});
|
});
|
||||||
w[1].on('end', function(received) {
|
w[1].on('end', function(received) {
|
||||||
t.same(received, expect, 'second');
|
assert.strict(received, expect, 'second');
|
||||||
if (--c === 0) t.end();
|
if (--c === 0) t.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -306,13 +306,13 @@ test('multipipe', function(t) {
|
|||||||
|
|
||||||
w[0].on('end', function(results) {
|
w[0].on('end', function(results) {
|
||||||
ended++;
|
ended++;
|
||||||
t.same(results, expect[0]);
|
assert.strict(results, expect[0]);
|
||||||
});
|
});
|
||||||
|
|
||||||
w[1].on('end', function(results) {
|
w[1].on('end', function(results) {
|
||||||
ended++;
|
ended++;
|
||||||
t.equal(ended, 2);
|
t.equal(ended, 2);
|
||||||
t.same(results, expect[1]);
|
assert.strict(results, expect[1]);
|
||||||
t.end();
|
t.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -323,7 +323,7 @@ test('multipipe', function(t) {
|
|||||||
|
|
||||||
test('back pressure respected', function(t) {
|
test('back pressure respected', function(t) {
|
||||||
const r = new R({ objectMode: true });
|
const r = new R({ objectMode: true });
|
||||||
r._read = common.noop;
|
r._read = common.mustNotCall();
|
||||||
let counter = 0;
|
let counter = 0;
|
||||||
r.push(['one']);
|
r.push(['one']);
|
||||||
r.push(['two']);
|
r.push(['two']);
|
||||||
@ -341,7 +341,7 @@ test('back pressure respected', function(t) {
|
|||||||
r.pipe(w3);
|
r.pipe(w3);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
w1.end = common.noop;
|
w1.end = common.mustNotCall();
|
||||||
|
|
||||||
r.pipe(w1);
|
r.pipe(w1);
|
||||||
|
|
||||||
@ -367,7 +367,7 @@ test('back pressure respected', function(t) {
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
w2.end = common.noop;
|
w2.end = common.mustCall();
|
||||||
|
|
||||||
const w3 = new R();
|
const w3 = new R();
|
||||||
w3.write = function(chunk) {
|
w3.write = function(chunk) {
|
||||||
@ -400,7 +400,7 @@ test('read(0) for ended streams', function(t) {
|
|||||||
const r = new R();
|
const r = new R();
|
||||||
let written = false;
|
let written = false;
|
||||||
let ended = false;
|
let ended = false;
|
||||||
r._read = common.noop;
|
r._read = common.mustNotCall();
|
||||||
|
|
||||||
r.push(Buffer.from('foo'));
|
r.push(Buffer.from('foo'));
|
||||||
r.push(null);
|
r.push(null);
|
||||||
@ -471,7 +471,7 @@ test('adding readable triggers data flow', function(t) {
|
|||||||
|
|
||||||
test('chainable', function(t) {
|
test('chainable', function(t) {
|
||||||
const r = new R();
|
const r = new R();
|
||||||
r._read = common.noop;
|
r._read = common.mustCall();
|
||||||
const r2 = r.setEncoding('utf8').pause().resume().pause();
|
const r2 = r.setEncoding('utf8').pause().resume().pause();
|
||||||
t.equal(r, r2);
|
t.equal(r, r2);
|
||||||
t.end();
|
t.end();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user