-
Notifications
You must be signed in to change notification settings - Fork 30.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor and simplify parallel/test-timer-close.js. Add comment to describe the test case.
- Loading branch information
1 parent
e1fedfb
commit 3a480ed
Showing
1 changed file
with
7 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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')); |