File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -72,6 +72,23 @@ export function test_setTimeout_callbackCalledAfterSpecifiedTime() {
7272 TKUnit . assert ( completed , "Callback should be called after the specified time!" ) ;
7373}
7474
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+
7592export function test_setTimeout_callbackNotCalled ( ) {
7693 let completed = false ;
7794
Original file line number Diff line number Diff line change @@ -16,6 +16,9 @@ function createHandlerAndGetId(): number {
1616}
1717
1818export function setTimeout ( callback : Function , milliseconds = 0 , ...args ) : number {
19+ // Cast to Number
20+ milliseconds += 0 ;
21+
1922 const id = createHandlerAndGetId ( ) ;
2023 const invoke = ( ) => callback ( ...args ) ;
2124 const zoneBound = zonedCallback ( invoke ) ;
@@ -48,6 +51,9 @@ export function clearTimeout(id: number): void {
4851}
4952
5053export function setInterval ( callback : Function , milliseconds = 0 , ...args ) : number {
54+ // Cast to Number
55+ milliseconds += 0 ;
56+
5157 const id = createHandlerAndGetId ( ) ;
5258 const handler = timeoutHandler ;
5359 const invoke = ( ) => callback ( ...args ) ;
Original file line number Diff line number Diff line change @@ -48,6 +48,9 @@ class TimerTargetImpl extends NSObject {
4848}
4949
5050function createTimerAndGetId ( callback : Function , milliseconds : number , shouldRepeat : boolean ) : number {
51+ // Cast to Number
52+ milliseconds += 0 ;
53+
5154 timerId ++ ;
5255 let id = timerId ;
5356 let timerTarget = TimerTargetImpl . initWithCallback ( callback , id , shouldRepeat ) ;
You can’t perform that action at this time.
0 commit comments