mirror of
https://github.com/nodejs/node.git
synced 2026-11-27 17:52:27 -05:00
test: refactor test-timer-close
Refactor and simplify parallel/test-timer-close.js. Add comment to describe the test case. PR-URL: https://github.com/nodejs/node/pull/10517 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
This commit is contained in:
1 parent
dd9aefde69
commit
eba9add48e
1 file changed
+7
-12
@@ -1,16 +1,11 @@
|
||||
'use strict';
|
||||
require('../common');
|
||||
const assert = require('assert');
|
||||
const common = require('../common');
|
||||
|
||||
var t = new (process.binding('timer_wrap').Timer)();
|
||||
var called = 0;
|
||||
function onclose() {
|
||||
called++;
|
||||
}
|
||||
// Make sure handle._handle.close(callback) is idempotent by closing a timer
|
||||
// twice. The first function should be called, the second one should not.
|
||||
|
||||
t.close(onclose);
|
||||
t.close(onclose);
|
||||
const Timer = process.binding('timer_wrap').Timer;
|
||||
const t = new Timer();
|
||||
|
||||
process.on('exit', function() {
|
||||
assert.equal(1, called);
|
||||
});
|
||||
t.close(common.mustCall(function() {}));
|
||||
t.close(() => common.fail('This should never be called'));
|
||||
Reference in new issue
Block a user