mirror of
https://github.com/nodejs/node.git
synced 2025-05-09 12:20:18 +00:00

Export a new common.noop no-operation function for general use. Allow using common.mustCall() without a fn argument to simplify test cases. Replace various non-op functions throughout tests with common.noop PR-URL: https://github.com/nodejs/node/pull/12027 Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Teddy Katz <teddy.katz@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
21 lines
373 B
JavaScript
21 lines
373 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
|
|
let once = 0;
|
|
|
|
process.on('beforeExit', () => {
|
|
if (once > 1)
|
|
throw new RangeError('beforeExit should only have been called once!');
|
|
|
|
setTimeout(common.noop, 1).unref();
|
|
once++;
|
|
});
|
|
|
|
process.on('exit', (code) => {
|
|
if (code !== 0) return;
|
|
|
|
assert.strictEqual(once, 1);
|
|
});
|