Skip to content

Commit af058e9

Browse files
committed
wip: fix build fail on older Swift version
1 parent 4568dcb commit af058e9

9 files changed

+172
-176
lines changed

Tests/AsyncObjectsTests/AsyncCountdownEventTests.swift

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -6,74 +6,74 @@ class AsyncCountdownEventTests: XCTestCase {
66

77
func testWithoutIncrement() async throws {
88
let event = AsyncCountdownEvent()
9-
try await event.wait(forSeconds: 3)
9+
try await event.wait(forSeconds: 5)
1010
}
1111

1212
func testWithIncrement() async throws {
1313
let event = AsyncCountdownEvent()
1414
event.increment(by: 10)
1515
event.signal(concurrent: 10)
16-
try await event.wait(forSeconds: 3)
16+
try await event.wait(forSeconds: 5)
1717
}
1818

1919
func testWithOverIncrement() async throws {
2020
let event = AsyncCountdownEvent()
2121
event.increment(by: 10)
2222
event.signal(concurrent: 15)
23-
try await event.wait(forSeconds: 3)
24-
try await waitUntil(event, timeout: 3) { $0.currentCount == 0 }
23+
try await event.wait(forSeconds: 5)
24+
try await waitUntil(event, timeout: 5) { $0.currentCount == 0 }
2525
}
2626

2727
func testWithLimitAndIncrement() async throws {
2828
let event = AsyncCountdownEvent(until: 3)
2929
event.increment(by: 10)
3030
event.signal(concurrent: 7)
31-
try await event.wait(forSeconds: 3)
31+
try await event.wait(forSeconds: 5)
3232
}
3333

3434
func testWithLimitInitialCountAndIncrement() async throws {
3535
let event = AsyncCountdownEvent(until: 3, initial: 2)
3636
event.increment(by: 10)
3737
event.signal(concurrent: 9)
38-
try await event.wait(forSeconds: 3)
38+
try await event.wait(forSeconds: 5)
3939
}
4040

4141
func testWithIncrementAndReset() async throws {
4242
let event = AsyncCountdownEvent()
4343
event.increment(by: 10)
44-
try await waitUntil(event, timeout: 3) { $0.currentCount == 10 }
44+
try await waitUntil(event, timeout: 5) { $0.currentCount == 10 }
4545
event.reset()
46-
try await event.wait(forSeconds: 3)
46+
try await event.wait(forSeconds: 5)
4747
}
4848

4949
func testWithIncrementAndResetToCount() async throws {
5050
let event = AsyncCountdownEvent()
5151
event.increment(by: 10)
52-
try await waitUntil(event, timeout: 3) { $0.currentCount == 10 }
52+
try await waitUntil(event, timeout: 5) { $0.currentCount == 10 }
5353
event.reset(to: 2)
54-
try await waitUntil(event, timeout: 3) { $0.currentCount == 2 }
54+
try await waitUntil(event, timeout: 5) { $0.currentCount == 2 }
5555
event.signal(concurrent: 2)
56-
try await event.wait(forSeconds: 3)
56+
try await event.wait(forSeconds: 5)
5757
}
5858

5959
func testWithConcurrentIncrementAndResetToCount() async throws {
6060
let event = AsyncCountdownEvent()
6161
event.increment(by: 10)
62-
try await waitUntil(event, timeout: 3) { $0.currentCount == 10 }
62+
try await waitUntil(event, timeout: 5) { $0.currentCount == 10 }
6363
Task.detached {
64-
try await waitUntil(event, timeout: 3) { $0.currentCount == 6 }
64+
try await waitUntil(event, timeout: 5) { $0.currentCount == 6 }
6565
event.reset(to: 2)
6666
}
6767
event.signal(concurrent: 4)
68-
try await waitUntil(event, timeout: 3) { $0.currentCount == 2 }
68+
try await waitUntil(event, timeout: 5) { $0.currentCount == 2 }
6969
event.signal(concurrent: 2)
70-
try await event.wait(forSeconds: 3)
70+
try await event.wait(forSeconds: 5)
7171
}
7272

7373
func testDeinit() async throws {
7474
let event = AsyncCountdownEvent(until: 0, initial: 1)
7575
Task.detached { event.signal() }
76-
try await event.wait(forSeconds: 3)
76+
try await event.wait(forSeconds: 5)
7777
self.addTeardownBlock { [weak event] in
7878
event.assertReleased()
7979
}
@@ -85,7 +85,7 @@ class AsyncCountdownEventTests: XCTestCase {
8585
group.addTask {
8686
let event = AsyncCountdownEvent(initial: 1)
8787
try await withThrowingTaskGroup(of: Void.self) { g in
88-
g.addTask { try await event.wait(forSeconds: 3) }
88+
g.addTask { try await event.wait(forSeconds: 5) }
8989
g.addTask { event.signal() }
9090
try await g.waitForAll()
9191
}
@@ -102,56 +102,56 @@ class AsyncCountdownEventTimeoutTests: XCTestCase {
102102
func testTimeoutWithIncrement() async throws {
103103
let event = AsyncCountdownEvent()
104104
event.increment(by: 10)
105-
try await waitUntil(event, timeout: 3) { $0.currentCount == 10 }
105+
try await waitUntil(event, timeout: 5) { $0.currentCount == 10 }
106106
event.signal(concurrent: 9)
107107
do {
108-
try await event.wait(forSeconds: 3)
108+
try await event.wait(forSeconds: 5)
109109
XCTFail("Unexpected task progression")
110110
} catch is DurationTimeoutError {
111-
try await waitUntil(event, timeout: 3) { $0.currentCount == 1 }
111+
try await waitUntil(event, timeout: 5) { $0.currentCount == 1 }
112112
}
113113
}
114114

115115
func testTimeoutWithLimitAndIncrement() async throws {
116116
let event = AsyncCountdownEvent(until: 3)
117117
event.increment(by: 10)
118-
try await waitUntil(event, timeout: 3) { $0.currentCount == 10 }
118+
try await waitUntil(event, timeout: 5) { $0.currentCount == 10 }
119119
event.signal(concurrent: 6)
120120
do {
121-
try await event.wait(forSeconds: 3)
121+
try await event.wait(forSeconds: 5)
122122
XCTFail("Unexpected task progression")
123123
} catch is DurationTimeoutError {
124-
try await waitUntil(event, timeout: 3) { $0.currentCount == 4 }
124+
try await waitUntil(event, timeout: 5) { $0.currentCount == 4 }
125125
}
126126
}
127127

128128
func testTimeoutWithLimitInitialCountAndIncrement() async throws {
129129
let event = AsyncCountdownEvent(until: 3, initial: 3)
130130
event.increment(by: 10)
131-
try await waitUntil(event, timeout: 3) { $0.currentCount == 13 }
131+
try await waitUntil(event, timeout: 5) { $0.currentCount == 13 }
132132
event.signal(concurrent: 9)
133133
do {
134-
try await event.wait(forSeconds: 3)
134+
try await event.wait(forSeconds: 5)
135135
XCTFail("Unexpected task progression")
136136
} catch is DurationTimeoutError {
137-
try await waitUntil(event, timeout: 3) { $0.currentCount == 4 }
137+
try await waitUntil(event, timeout: 5) { $0.currentCount == 4 }
138138
}
139139
}
140140

141141
func testTimeoutWithIncrementAndResetToCount() async throws {
142142
let event = AsyncCountdownEvent()
143143
event.increment(by: 10)
144-
try await waitUntil(event, timeout: 3) { $0.currentCount == 10 }
144+
try await waitUntil(event, timeout: 5) { $0.currentCount == 10 }
145145
event.signal(concurrent: 8)
146146
Task.detached {
147-
try await waitUntil(event, timeout: 3) { $0.currentCount <= 6 }
147+
try await waitUntil(event, timeout: 5) { $0.currentCount <= 6 }
148148
event.reset(to: 6)
149149
}
150150
do {
151-
try await event.wait(forSeconds: 3)
151+
try await event.wait(forSeconds: 5)
152152
XCTFail("Unexpected task progression")
153153
} catch is DurationTimeoutError {
154-
try await waitUntil(event, timeout: 3) {
154+
try await waitUntil(event, timeout: 5) {
155155
[6, 2].contains($0.currentCount)
156156
}
157157
}
@@ -171,13 +171,13 @@ class AsyncCountdownEventClockTimeoutTests: XCTestCase {
171171
let clock: ContinuousClock = .continuous
172172
let event = AsyncCountdownEvent()
173173
event.increment(by: 10)
174-
try await waitUntil(event, timeout: 3) { $0.currentCount == 10 }
174+
try await waitUntil(event, timeout: 5) { $0.currentCount == 10 }
175175
event.signal(concurrent: 9)
176176
do {
177-
try await event.wait(forSeconds: 3, clock: clock)
177+
try await event.wait(forSeconds: 5, clock: clock)
178178
XCTFail("Unexpected task progression")
179179
} catch is TimeoutError<ContinuousClock> {
180-
try await waitUntil(event, timeout: 3) { $0.currentCount == 1 }
180+
try await waitUntil(event, timeout: 5) { $0.currentCount == 1 }
181181
}
182182
}
183183

@@ -190,13 +190,13 @@ class AsyncCountdownEventClockTimeoutTests: XCTestCase {
190190
let clock: ContinuousClock = .continuous
191191
let event = AsyncCountdownEvent(until: 3)
192192
event.increment(by: 10)
193-
try await waitUntil(event, timeout: 3) { $0.currentCount == 10 }
193+
try await waitUntil(event, timeout: 5) { $0.currentCount == 10 }
194194
event.signal(concurrent: 6)
195195
do {
196-
try await event.wait(forSeconds: 3, clock: clock)
196+
try await event.wait(forSeconds: 5, clock: clock)
197197
XCTFail("Unexpected task progression")
198198
} catch is TimeoutError<ContinuousClock> {
199-
try await waitUntil(event, timeout: 3) { $0.currentCount == 4 }
199+
try await waitUntil(event, timeout: 5) { $0.currentCount == 4 }
200200
}
201201
}
202202

@@ -209,13 +209,13 @@ class AsyncCountdownEventClockTimeoutTests: XCTestCase {
209209
let clock: ContinuousClock = .continuous
210210
let event = AsyncCountdownEvent(until: 3, initial: 3)
211211
event.increment(by: 10)
212-
try await waitUntil(event, timeout: 3) { $0.currentCount == 13 }
212+
try await waitUntil(event, timeout: 5) { $0.currentCount == 13 }
213213
event.signal(concurrent: 9)
214214
do {
215-
try await event.wait(forSeconds: 3, clock: clock)
215+
try await event.wait(forSeconds: 5, clock: clock)
216216
XCTFail("Unexpected task progression")
217217
} catch is TimeoutError<ContinuousClock> {
218-
try await waitUntil(event, timeout: 3) { $0.currentCount == 4 }
218+
try await waitUntil(event, timeout: 5) { $0.currentCount == 4 }
219219
}
220220
}
221221

@@ -228,17 +228,17 @@ class AsyncCountdownEventClockTimeoutTests: XCTestCase {
228228
let clock: ContinuousClock = .continuous
229229
let event = AsyncCountdownEvent()
230230
event.increment(by: 10)
231-
try await waitUntil(event, timeout: 3) { $0.currentCount == 10 }
231+
try await waitUntil(event, timeout: 5) { $0.currentCount == 10 }
232232
event.signal(concurrent: 8)
233233
Task.detached {
234-
try await waitUntil(event, timeout: 3) { $0.currentCount <= 6 }
234+
try await waitUntil(event, timeout: 5) { $0.currentCount <= 6 }
235235
event.reset(to: 6)
236236
}
237237
do {
238-
try await event.wait(forSeconds: 3, clock: clock)
238+
try await event.wait(forSeconds: 5, clock: clock)
239239
XCTFail("Unexpected task progression")
240240
} catch is TimeoutError<ContinuousClock> {
241-
try await waitUntil(event, timeout: 3) { $0.currentCount <= 6 }
241+
try await waitUntil(event, timeout: 5) { $0.currentCount <= 6 }
242242
}
243243
}
244244
}

Tests/AsyncObjectsTests/AsyncEventTests.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,26 @@ class AsyncEventTests: XCTestCase {
77
func testSignal() async throws {
88
let event = AsyncEvent(signaledInitially: false)
99
event.signal()
10-
try await event.wait(forSeconds: 3)
10+
try await event.wait(forSeconds: 5)
1111
}
1212

1313
func testResetSignal() async throws {
1414
let event = AsyncEvent()
1515
event.reset()
16-
try await waitUntil(event, timeout: 3) { !$0.signalled }
16+
try await waitUntil(event, timeout: 5) { !$0.signalled }
1717
event.signal()
18-
try await event.wait(forSeconds: 3)
18+
try await event.wait(forSeconds: 5)
1919
}
2020

2121
func testSignalled() async throws {
2222
let event = AsyncEvent()
23-
try await event.wait(forSeconds: 3)
23+
try await event.wait(forSeconds: 5)
2424
}
2525

2626
func testDeinit() async throws {
2727
let event = AsyncEvent(signaledInitially: false)
2828
Task.detached { event.signal() }
29-
try await event.wait(forSeconds: 3)
29+
try await event.wait(forSeconds: 5)
3030
self.addTeardownBlock { [weak event] in
3131
event.assertReleased()
3232
}
@@ -38,7 +38,7 @@ class AsyncEventTests: XCTestCase {
3838
group.addTask {
3939
let event = AsyncEvent(signaledInitially: false)
4040
try await withThrowingTaskGroup(of: Void.self) { g in
41-
g.addTask { try await event.wait(forSeconds: 3) }
41+
g.addTask { try await event.wait(forSeconds: 5) }
4242
g.addTask { event.signal() }
4343
try await g.waitForAll()
4444
}
@@ -55,17 +55,17 @@ class AsyncEventTimeoutTests: XCTestCase {
5555
func testSignal() async throws {
5656
let event = AsyncEvent(signaledInitially: false)
5757
do {
58-
try await event.wait(forSeconds: 3)
58+
try await event.wait(forSeconds: 5)
5959
XCTFail("Unexpected task progression")
6060
} catch is DurationTimeoutError {}
6161
}
6262

6363
func testResetSignal() async throws {
6464
let event = AsyncEvent()
6565
event.reset()
66-
try await waitUntil(event, timeout: 3) { !$0.signalled }
66+
try await waitUntil(event, timeout: 5) { !$0.signalled }
6767
do {
68-
try await event.wait(forSeconds: 3)
68+
try await event.wait(forSeconds: 5)
6969
XCTFail("Unexpected task progression")
7070
} catch is DurationTimeoutError {}
7171
}
@@ -84,7 +84,7 @@ class AsyncEventClockTimeoutTests: XCTestCase {
8484
let clock: ContinuousClock = .continuous
8585
let event = AsyncEvent(signaledInitially: false)
8686
do {
87-
try await event.wait(forSeconds: 3, clock: clock)
87+
try await event.wait(forSeconds: 5, clock: clock)
8888
XCTFail("Unexpected task progression")
8989
} catch is TimeoutError<ContinuousClock> {}
9090
}
@@ -98,9 +98,9 @@ class AsyncEventClockTimeoutTests: XCTestCase {
9898
let clock: ContinuousClock = .continuous
9999
let event = AsyncEvent()
100100
event.reset()
101-
try await waitUntil(event, timeout: 3) { !$0.signalled }
101+
try await waitUntil(event, timeout: 5) { !$0.signalled }
102102
do {
103-
try await event.wait(forSeconds: 3, clock: clock)
103+
try await event.wait(forSeconds: 5, clock: clock)
104104
XCTFail("Unexpected task progression")
105105
} catch is TimeoutError<ContinuousClock> {}
106106
}

0 commit comments

Comments
 (0)