test: provide duration/interval to timers
There are places in the code base where setTimeout() or setInterval() are called with just a callback and no duration/interval. The timers module will use a value of `1` in that situation. An unspecified duration or interval can be confusing. Did the original author forget to provide a value? Did they intend to use setImmediate() or process.nextTick() instead of setTimeout()? And so on. This change provides a duration or interval of `1` to all calls in the codebase where it is missing. `parallel/test-timers.js` still tests the situation where `setTimeout()` and `setInterval()` are called with `undefined` and other non-numeric values for the duration/interval. PR-URL: https://github.com/nodejs/node/pull/9472 Reviewed-By: Teddy Katz <teddy.katz@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
38b18e330f
commit
6263c00828
@ -4,4 +4,4 @@ require('../common');
|
||||
setTimeout(function() {
|
||||
// eslint-disable-next-line no-undef
|
||||
undefined_reference_error_maker;
|
||||
});
|
||||
}, 1);
|
||||
|
@ -13,4 +13,4 @@ setTimeout(function() {
|
||||
setTimeout(function() {
|
||||
throw new Error('setTimeout');
|
||||
}, 1);
|
||||
});
|
||||
}, 1);
|
||||
|
@ -21,7 +21,7 @@ stream.pause();
|
||||
setTimeout(common.mustCall(function() {
|
||||
stream.on('end', common.mustCall(function() {}));
|
||||
stream.resume();
|
||||
}));
|
||||
}), 1);
|
||||
|
||||
process.on('exit', function() {
|
||||
assert(calledRead);
|
||||
|
@ -20,7 +20,7 @@ const Readable = require('stream').Readable;
|
||||
// we're testing what we think we are
|
||||
assert(!r._readableState.reading);
|
||||
r.on('readable', common.mustCall(function() {}));
|
||||
});
|
||||
}, 1);
|
||||
}
|
||||
|
||||
{
|
||||
@ -40,7 +40,7 @@ const Readable = require('stream').Readable;
|
||||
// assert we're testing what we think we are
|
||||
assert(r._readableState.reading);
|
||||
r.on('readable', common.mustCall(function() {}));
|
||||
});
|
||||
}, 1);
|
||||
}
|
||||
|
||||
{
|
||||
@ -60,5 +60,5 @@ const Readable = require('stream').Readable;
|
||||
// assert we're testing what we think we are
|
||||
assert(!r._readableState.reading);
|
||||
r.on('readable', common.mustCall(function() {}));
|
||||
});
|
||||
}, 1);
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ function push() {
|
||||
|
||||
console.error(' push #%d', pushes);
|
||||
if (r.push(Buffer.allocUnsafe(PUSHSIZE)))
|
||||
setTimeout(push);
|
||||
setTimeout(push, 1);
|
||||
}
|
||||
|
||||
process.on('exit', function() {
|
||||
|
@ -16,7 +16,7 @@ test._read = function(size) {
|
||||
var chunk = chunks[n++];
|
||||
setTimeout(function() {
|
||||
test.push(chunk === undefined ? null : chunk);
|
||||
});
|
||||
}, 1);
|
||||
};
|
||||
|
||||
test.on('end', thrower);
|
||||
@ -31,7 +31,7 @@ test.on('readable', function() {
|
||||
if (res) {
|
||||
bytesread += res.length;
|
||||
console.error('br=%d len=%d', bytesread, len);
|
||||
setTimeout(next);
|
||||
setTimeout(next, 1);
|
||||
}
|
||||
test.read(0);
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user