| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent b808013 commit 456fd75
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -49,12 +49,24 @@ function tryListen() { | |||
| 49 | 49 | // Test that a function invoked from the beforeExit handler can use a timer | |
| 50 | 50 | // to keep the event loop open, which can use another timer to keep the event | |
| 51 | 51 | // loop open, etc. | |
| 52 | + // | ||
| 53 | + // After N times, call function `tryNextTick` to test behaviors of the | ||
| 54 | + // `process.nextTick`. | ||
| 52 | 55 | function tryRepeatedTimer() { | |
| 53 | 56 | const N = 5; | |
| 54 | 57 | let n = 0; | |
| 55 | 58 | const repeatedTimer = common.mustCall(function() { | |
| 56 | 59 | if (++n < N) | |
| 57 | 60 | setTimeout(repeatedTimer, 1); | |
| 61 | + else // n == N | ||
| 62 | + process.once('beforeExit', common.mustCall(tryNextTick)); | ||
| 58 | 63 | }, N); | |
| 59 | 64 | setTimeout(repeatedTimer, 1); | |
| 60 | 65 | } | |
| 66 | + | ||
| 67 | + // Test if the callback of `process.nextTick` can be invoked. | ||
| 68 | + function tryNextTick() { | ||
| 69 | + process.nextTick(common.mustCall(function() { | ||
| 70 | + process.once('beforeExit', common.mustNotCall()); | ||
| 71 | + })); | ||
| 72 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments