| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -72,6 +72,23 @@ export function test_setTimeout_callbackCalledAfterSpecifiedTime() { | |||
| 72 | 72 | TKUnit.assert(completed, "Callback should be called after the specified time!"); | |
| 73 | 73 | } | |
| 74 | 74 | ||
| 75 | + export function test_setTimeout_callbackCalledWithBooleanPeriod() { | ||
| 76 | + let completed = false; | ||
| 77 | + | ||
| 78 | + // >> timer-set-false | ||
| 79 | + const id = timer.setTimeout(() => { | ||
| 80 | + // >> (hide) | ||
| 81 | + completed = true; | ||
| 82 | + // << (hide) | ||
| 83 | + // @ts-ignore | ||
| 84 | + }, false); | ||
| 85 | + // << timer-set-false | ||
| 86 | + | ||
| 87 | + TKUnit.waitUntilReady(() => completed, 1); | ||
| 88 | + timer.clearTimeout(id); | ||
| 89 | + TKUnit.assert(completed, "Callback should be called in 0 seconds!"); | ||
| 90 | + } | ||
| 91 | + | ||
| 75 | 92 | export function test_setTimeout_callbackNotCalled() { | |
| 76 | 93 | let completed = false; | |
| 77 | 94 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -16,6 +16,9 @@ function createHandlerAndGetId(): number { | |||
| 16 | 16 | } | |
| 17 | 17 | ||
| 18 | 18 | export function setTimeout(callback: Function, milliseconds = 0, ...args): number { | |
| 19 | + // Cast to Number | ||
| 20 | + milliseconds += 0; | ||
| 21 | + | ||
| 19 | 22 | const id = createHandlerAndGetId(); | |
| 20 | 23 | const invoke = () => callback(...args); | |
| 21 | 24 | const zoneBound = zonedCallback(invoke); | |
@@ -48,6 +51,9 @@ export function clearTimeout(id: number): void { | |||
| 48 | 51 | } | |
| 49 | 52 | ||
| 50 | 53 | export function setInterval(callback: Function, milliseconds = 0, ...args): number { | |
| 54 | + // Cast to Number | ||
| 55 | + milliseconds += 0; | ||
| 56 | + | ||
| 51 | 57 | const id = createHandlerAndGetId(); | |
| 52 | 58 | const handler = timeoutHandler; | |
| 53 | 59 | const invoke = () => callback(...args); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -48,6 +48,9 @@ class TimerTargetImpl extends NSObject { | |||
| 48 | 48 | } | |
| 49 | 49 | ||
| 50 | 50 | function createTimerAndGetId(callback: Function, milliseconds: number, shouldRepeat: boolean): number { | |
| 51 | + // Cast to Number | ||
| 52 | + milliseconds += 0; | ||
| 53 | + | ||
| 51 | 54 | timerId++; | |
| 52 | 55 | let id = timerId; | |
| 53 | 56 | let timerTarget = TimerTargetImpl.initWithCallback(callback, id, shouldRepeat); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments