Skip to content

Commit

Permalink
test: refactor test-timer-close
Browse files Browse the repository at this point in the history
Refactor and simplify parallel/test-timer-close.js. Add comment to
describe the test case.

PR-URL: #10517
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Santiago Gimeno <[email protected]>
Reviewed-By: Jeremiah Senkpiel <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Gibson Fahnestock <[email protected]>
  • Loading branch information
BethGriggs authored and italoacasas committed Jan 30, 2017
1 parent dd9aefd commit eba9add
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions test/parallel/test-timer-close.js
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'));

0 comments on commit eba9add

Please sign in to comment.