Sha256: eb6640015593f62f397aff8ba474b2e2129e24c16e70afd3dfb02582dac4e924

Contents?: true

Size: 1.2 KB

Versions: 5

Compression:

Stored size: 1.2 KB

Contents

'use strict';

// https://github.com/nodejs/node/pull/2540/files#r38231197

const common = require('../common');
const timers = require('timers');
const assert = require('assert');
const domain = require('domain');

// Crazy stuff to keep the process open,
// then close it when we are actually done.
const TEST_DURATION = common.platformTimeout(1000);
const keepOpen = setTimeout(function() {
  throw new Error('Test timed out. keepOpen was not canceled.');
}, TEST_DURATION);

const endTest = makeTimer(2);

const someTimer = makeTimer(1);
someTimer.domain = domain.create();
someTimer.domain.dispose();
someTimer._onTimeout = function() {
  throw new Error('someTimer was not supposed to fire!');
};

endTest._onTimeout = common.mustCall(function() {
  assert.strictEqual(someTimer._idlePrev, null);
  assert.strictEqual(someTimer._idleNext, null);
  clearTimeout(keepOpen);
});

const cancelsTimer = makeTimer(1);
cancelsTimer._onTimeout = common.mustCall(function() {
  someTimer._idleTimeout = 0;
});

timers._unrefActive(cancelsTimer);
timers._unrefActive(someTimer);
timers._unrefActive(endTest);

function makeTimer(msecs) {
  const timer = {};
  timers.unenroll(timer);
  timers.enroll(timer, msecs);
  return timer;
}

Version data entries

5 entries across 4 versions & 1 rubygems

Version Path
node-compiler-0.9.1 vendor/node/test/parallel/test-timers-unref-active-unenrolled-disposed.js
node-compiler-0.9.0 vendor/node-v7.2.1/test/parallel/test-timers-unref-active-unenrolled-disposed.js
node-compiler-0.8.0 vendor/node-v7.2.0/test/parallel/test-timers-unref-active-unenrolled-disposed.js
node-compiler-0.7.0 vendor/node-v6.9.1/test/parallel/test-timers-unref-active-unenrolled-disposed.js
node-compiler-0.7.0 vendor/node-v7.1.0/test/parallel/test-timers-unref-active-unenrolled-disposed.js