FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
SwiftyTimer/SwiftyTimerTests/SwiftyTimerTests/main.swift at master · radex/SwiftyTimer · GitHub
This repository was archived by the owner on May 1, 2026. It is now read-only.
radex
SwiftyTimer
Repository navigation
Code
Issues
6
(6)
Pull requests
4
(4)
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
SwiftyTimer
/
SwiftyTimerTests
/
SwiftyTimerTests
/
main.swift
Copy path
More file actions
More file actions
Latest commit
History
History
History
119 lines (100 loc) · 2.77 KB
Breadcrumbs
SwiftyTimer
/
SwiftyTimerTests
/
SwiftyTimerTests
/
main.swift
Copy path
File metadata and controls
119 lines (100 loc) · 2.77 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
import
Cocoa
let
app
=
NSApplication
.
shared
class
AppDelegate
:
NSObject
,
NSApplicationDelegate
{
func
applicationDidFinishLaunching
(
_ aNotification
:
Notification
)
{
test
(
)
}
func
test
(
)
{
assert
(
1
.
second
==
1.0
)
assert
(
1
.
minute
==
60.0
)
assert
(
1
.
hour
==
1
.
minute
*
60
)
assert
(
1.2
.
seconds
==
1.2
)
assert
(
1.5
.
minutes
==
90.0
)
assert
(
1.5
.
hours
==
5400.0
)
assert
(
1.3
.
milliseconds
==
0.0013
)
assert
(
0.5
.
day
==
43_200
)
assert
(
1
.
day
==
86_400
)
assert
(
2
.
days
==
172_800
)
test2
(
)
}
func
test2
(
)
{
var
fired
=
false
Timer
.
after
(
0.1
.
seconds
)
{
assert
(
!fired
)
fired
=
true
self
.
test3
(
)
}
}
var
timer1
:
Timer
!
func
test3
(
)
{
var
fired
=
false
timer1
=
Timer
.
every
(
0.1
.
seconds
)
{
if
fired
{
self
.
test4
(
)
self
.
timer1
.
invalidate
(
)
}
else
{
fired
=
true
}
}
}
let
timer2
=
Timer
.
new
(
after
:
0.1
.
seconds
)
{
fatalError
(
)
}
let
timer3
=
Timer
.
new
(
every
:
0.1
.
seconds
)
{
fatalError
(
)
}
func
test4
(
)
{
let
timer
=
Timer
.
new
(
after
:
0.1
.
seconds
)
{
self
.
test5
(
)
}
RunLoop
.
current
.
add
(
timer
,
forMode
:
.
default
)
}
var
timer4
:
Timer
!
func
test5
(
)
{
var
fired
=
false
timer4
=
Timer
.
new
(
every
:
0.1
.
seconds
)
{
if
fired
{
self
.
timer4
.
invalidate
(
)
self
.
test6
(
)
}
else
{
fired
=
true
}
}
timer4
.
start
(
)
}
func
test6
(
)
{
let
timer
=
Timer
.
new
(
after
:
0.1
.
seconds
)
{
self
.
test7
(
)
}
timer
.
start
(
runLoop
:
.
current
,
modes
:
.
default
,
.
eventTracking
)
}
func
test7
(
)
{
Timer
.
after
(
0.1
.
seconds
,
test8
)
}
func
test8
(
)
{
var
fires
=
0
let
timer
=
Timer
.
new
(
every
:
0.1
.
seconds
)
{
(
timer
:
Timer
)
in
guard
fires
<=
1
else
{
fatalError
(
"
should be invalidated
"
)
}
defer
{
fires
+=
1
}
if
fires
==
1
{
timer
.
invalidate
(
)
self
.
test9
(
)
}
}
timer
.
start
(
)
}
func
test9
(
)
{
var
fires
=
0
Timer
.
every
(
0.1
.
seconds
)
{
(
timer
:
Timer
)
in
guard
fires
<=
1
else
{
fatalError
(
"
should be invalidated
"
)
}
defer
{
fires
+=
1
}
if
fires
==
1
{
timer
.
invalidate
(
)
self
.
done
(
)
}
}
}
func
done
(
)
{
print
(
"
All tests passed
"
)
app
.
terminate
(
self
)
}
}
let
delegate
=
AppDelegate
(
)
app
.
delegate
=
delegate
app
.
run
(
)
Back
|
FazBrowse Home
|
New Git URL