mirror of
https://github.com/nodejs/node.git
synced 2025-05-06 11:29:26 +00:00

common.js needs to be loaded in all tests so that there is checking for variable leaks and possibly other things. However, it does not need to be assigned to a variable if nothing in common.js is referred to elsewhere in the test. PR-URL: https://github.com/nodejs/node/pull/4408 Reviewed-By: James M Snell <jasnell@gmail.com>
35 lines
855 B
JavaScript
35 lines
855 B
JavaScript
'use strict';
|
|
require('../common');
|
|
const assert = require('assert');
|
|
const active = require('timers').active;
|
|
|
|
// active() should create timers for these
|
|
var legitTimers = [
|
|
{ _idleTimeout: 0 },
|
|
{ _idleTimeout: 1 }
|
|
];
|
|
|
|
legitTimers.forEach(function(legit) {
|
|
const savedTimeout = legit._idleTimeout;
|
|
active(legit);
|
|
// active() should mutate these objects
|
|
assert(legit._idleTimeout === savedTimeout);
|
|
assert(Number.isInteger(legit._idleStart));
|
|
assert(legit._idleNext);
|
|
assert(legit._idlePrev);
|
|
});
|
|
|
|
|
|
// active() should not create a timer for these
|
|
var bogusTimers = [
|
|
{ _idleTimeout: -1 },
|
|
{ _idleTimeout: undefined },
|
|
];
|
|
|
|
bogusTimers.forEach(function(bogus) {
|
|
const savedTimeout = bogus._idleTimeout;
|
|
active(bogus);
|
|
// active() should not mutate these objects
|
|
assert.deepStrictEqual(bogus, {_idleTimeout: savedTimeout});
|
|
});
|