| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 80aeca7 commit efbed9c
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -16,16 +16,6 @@ const assert = require('assert'); | |||
| 16 | 16 | const Timer = process.binding('timer_wrap').Timer; | |
| 17 | 17 | ||
| 18 | 18 | const TIMEOUT = common.platformTimeout(100); | |
| 19 | - const start = Timer.now(); | ||
| 20 | - | ||
| 21 | - // This bug also prevents the erroneously dereferenced timer's callback | ||
| 22 | - // from being called, so we can't use it's execution or lack thereof | ||
| 23 | - // to assert that the bug is fixed. | ||
| 24 | - process.on('exit', function() { | ||
| 25 | - const end = Timer.now(); | ||
| 26 | - assert.equal(end - start < TIMEOUT * 2, true, | ||
| 27 | - 'Elapsed time does not include second timer\'s timeout.'); | ||
| 28 | - }); | ||
| 29 | 19 | ||
| 30 | 20 | const handle1 = setTimeout(common.mustCall(function() { | |
| 31 | 21 | // Cause the old TIMEOUT list to be deleted | |
@@ -42,39 +32,41 @@ const handle1 = setTimeout(common.mustCall(function() { | |||
| 42 | 32 | // erroneously deleted. If we are able to cancel the timer successfully, | |
| 43 | 33 | // the bug is fixed. | |
| 44 | 34 | clearTimeout(handle2); | |
| 35 | + | ||
| 45 | 36 | setImmediate(common.mustCall(function() { | |
| 46 | 37 | setImmediate(common.mustCall(function() { | |
| 47 | - const activeHandles = process._getActiveHandles(); | ||
| 48 | - const activeTimers = activeHandles.filter(function(handle) { | ||
| 49 | - return handle instanceof Timer; | ||
| 50 | - }); | ||
| 38 | + const activeTimers = getActiveTimers(); | ||
| 51 | 39 | ||
| 52 | 40 | // Make sure our clearTimeout succeeded. One timer finished and | |
| 53 | 41 | // the other was canceled, so none should be active. | |
| 54 | - assert.equal(activeTimers.length, 0, 'No Timers remain.'); | ||
| 42 | + assert.strictEqual(activeTimers.length, 0, 'Timers remain.'); | ||
| 55 | 43 | })); | |
| 56 | 44 | })); | |
| 57 | - }), 10); | ||
| 45 | + }), 1); | ||
| 58 | 46 | ||
| 59 | 47 | // Make sure our timers got added to the list. | |
| 60 | - const activeHandles = process._getActiveHandles(); | ||
| 61 | - const activeTimers = activeHandles.filter(function(handle) { | ||
| 62 | - return handle instanceof Timer; | ||
| 63 | - }); | ||
| 48 | + const activeTimers = getActiveTimers(); | ||
| 64 | 49 | const shortTimer = activeTimers.find(function(handle) { | |
| 65 | - return handle._list.msecs === 10; | ||
| 50 | + return handle._list.msecs === 1; | ||
| 66 | 51 | }); | |
| 67 | 52 | const longTimers = activeTimers.filter(function(handle) { | |
| 68 | 53 | return handle._list.msecs === TIMEOUT; | |
| 69 | 54 | }); | |
| 70 | 55 | ||
| 71 | 56 | // Make sure our clearTimeout succeeded. One timer finished and | |
| 72 | 57 | // the other was canceled, so none should be active. | |
| 73 | - assert.equal(activeTimers.length, 3, 'There are 3 timers in the list.'); | ||
| 74 | - assert(shortTimer instanceof Timer, 'The shorter timer is in the list.'); | ||
| 75 | - assert.equal(longTimers.length, 2, 'Both longer timers are in the list.'); | ||
| 58 | + assert.strictEqual(activeTimers.length, 3, | ||
| 59 | + 'There should be 3 timers in the list.'); | ||
| 60 | + assert(shortTimer instanceof Timer, 'The shorter timer is not in the list.'); | ||
| 61 | + assert.strictEqual(longTimers.length, 2, | ||
| 62 | + 'Both longer timers should be in the list.'); | ||
| 76 | 63 | ||
| 77 | 64 | // When this callback completes, `listOnTimeout` should now look at the | |
| 78 | 65 | // correct list and refrain from removing the new TIMEOUT list which | |
| 79 | 66 | // contains the reference to the newer timer. | |
| 80 | 67 | }), TIMEOUT); | |
| 68 | + | ||
| 69 | + function getActiveTimers() { | ||
| 70 | + const activeHandles = process._getActiveHandles(); | ||
| 71 | + return activeHandles.filter((handle) => handle instanceof Timer); | ||
| 72 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments