test: improve assert error messages
Improve the assert error message so it includes actual value in the error message. PR-URL: https://github.com/nodejs/node/pull/21160 Reviewed-By: Weijia Wang <starkwang@126.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Yuta Hiroto <hello@hiroppy.me> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
872c331a93
commit
ef1f130041
@ -23,8 +23,12 @@ writer1._write = common.mustCall(function(chunk, encoding, cb) {
|
|||||||
}, 1);
|
}, 1);
|
||||||
|
|
||||||
writer1.once('chunk-received', function() {
|
writer1.once('chunk-received', function() {
|
||||||
assert.strictEqual(reader._readableState.awaitDrain, 0,
|
assert.strictEqual(
|
||||||
'initial value is not 0');
|
reader._readableState.awaitDrain,
|
||||||
|
0,
|
||||||
|
'awaitDrain initial value should be 0, actual is ' +
|
||||||
|
reader._readableState.awaitDrain
|
||||||
|
);
|
||||||
setImmediate(function() {
|
setImmediate(function() {
|
||||||
// This one should *not* get through to writer1 because writer2 is not
|
// This one should *not* get through to writer1 because writer2 is not
|
||||||
// "done" processing.
|
// "done" processing.
|
||||||
@ -35,8 +39,10 @@ writer1.once('chunk-received', function() {
|
|||||||
// A "slow" consumer:
|
// A "slow" consumer:
|
||||||
writer2._write = common.mustCall(function(chunk, encoding, cb) {
|
writer2._write = common.mustCall(function(chunk, encoding, cb) {
|
||||||
assert.strictEqual(
|
assert.strictEqual(
|
||||||
reader._readableState.awaitDrain, 1,
|
reader._readableState.awaitDrain,
|
||||||
'awaitDrain isn\'t 1 after first push'
|
1,
|
||||||
|
'awaitDrain should be 1 after first push, actual is ' +
|
||||||
|
reader._readableState.awaitDrain
|
||||||
);
|
);
|
||||||
// Not calling cb here to "simulate" slow stream.
|
// Not calling cb here to "simulate" slow stream.
|
||||||
// This should be called exactly once, since the first .write() call
|
// This should be called exactly once, since the first .write() call
|
||||||
@ -45,8 +51,10 @@ writer2._write = common.mustCall(function(chunk, encoding, cb) {
|
|||||||
|
|
||||||
writer3._write = common.mustCall(function(chunk, encoding, cb) {
|
writer3._write = common.mustCall(function(chunk, encoding, cb) {
|
||||||
assert.strictEqual(
|
assert.strictEqual(
|
||||||
reader._readableState.awaitDrain, 2,
|
reader._readableState.awaitDrain,
|
||||||
'awaitDrain isn\'t 2 after second push'
|
2,
|
||||||
|
'awaitDrain should be 2 after second push, actual is ' +
|
||||||
|
reader._readableState.awaitDrain
|
||||||
);
|
);
|
||||||
// Not calling cb here to "simulate" slow stream.
|
// Not calling cb here to "simulate" slow stream.
|
||||||
// This should be called exactly once, since the first .write() call
|
// This should be called exactly once, since the first .write() call
|
||||||
|
Loading…
x
Reference in New Issue
Block a user