Skip to content

Commit f57f2c7

Browse files
committed
Improve @test formatting
1 parent 2896687 commit f57f2c7

File tree

4 files changed

+110
-55
lines changed

4 files changed

+110
-55
lines changed

Tests/AsyncQueueTests/ActorQueueTests.swift

Lines changed: 46 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ struct ActorQueueTests {
3737

3838
// MARK: Behavior Tests
3939

40-
@Test func test_adoptExecutionContext_doesNotRetainActor() {
40+
@Test
41+
func adoptExecutionContext_doesNotRetainActor() {
4142
let systemUnderTest = ActorQueue<Counter>()
4243
var counter: Counter? = Counter()
4344
weak var weakCounter = counter
@@ -46,7 +47,8 @@ struct ActorQueueTests {
4647
#expect(weakCounter == nil)
4748
}
4849

49-
@Test func test_task_retainsAdoptedActorUntilEnqueuedTasksComplete() async {
50+
@Test
51+
func task_retainsAdoptedActorUntilEnqueuedTasksComplete() async {
5052
let systemUnderTest = ActorQueue<Counter>()
5153
var counter: Counter? = Counter()
5254
weak var weakCounter = counter
@@ -62,7 +64,8 @@ struct ActorQueueTests {
6264
await semaphore.signal()
6365
}
6466

65-
@Test func test_throwingTask_retainsAdoptedActorUntilEnqueuedTasksComplete() async {
67+
@Test
68+
func throwingTask_retainsAdoptedActorUntilEnqueuedTasksComplete() async {
6669
let systemUnderTest = ActorQueue<Counter>()
6770
var counter: Counter? = Counter()
6871
weak var weakCounter = counter
@@ -79,7 +82,8 @@ struct ActorQueueTests {
7982
await semaphore.signal()
8083
}
8184

82-
@Test func test_task_taskParameterIsAdoptedActor() async {
85+
@Test
86+
func task_taskParameterIsAdoptedActor() async {
8387
let semaphore = Semaphore()
8488
Task(on: systemUnderTest) { [storedCounter = counter] counter in
8589
#expect(counter === storedCounter)
@@ -89,7 +93,8 @@ struct ActorQueueTests {
8993
await semaphore.wait()
9094
}
9195

92-
@Test func test_throwingTask_taskParameterIsAdoptedActor() async {
96+
@Test
97+
func throwingTask_taskParameterIsAdoptedActor() async {
9398
let semaphore = Semaphore()
9499
Task(on: systemUnderTest) { [storedCounter = counter] counter in
95100
#expect(counter === storedCounter)
@@ -100,7 +105,8 @@ struct ActorQueueTests {
100105
await semaphore.wait()
101106
}
102107

103-
@Test func test_task_sendsEventsInOrder() async throws {
108+
@Test
109+
func task_sendsEventsInOrder() async throws {
104110
var lastTask: Task<Void, Never>?
105111
(1...1_000).forEach { iteration in
106112
lastTask = Task(on: systemUnderTest) { counter in
@@ -111,7 +117,8 @@ struct ActorQueueTests {
111117
try await #require(lastTask).value
112118
}
113119

114-
@Test func test_throwingTask_sendsEventsInOrder() async throws {
120+
@Test
121+
func throwingTask_sendsEventsInOrder() async throws {
115122
var lastTask: Task<Void, Error>?
116123
(1...1_000).forEach { iteration in
117124
lastTask = Task(on: systemUnderTest) { counter in
@@ -124,7 +131,8 @@ struct ActorQueueTests {
124131
}
125132

126133
@TestingQueue
127-
@Test func test_mainTask_sendsEventsInOrder() async throws {
134+
@Test
135+
func mainTask_sendsEventsInOrder() async throws {
128136
var lastTask: Task<Void, Error>?
129137
(1...1_000).forEach { iteration in
130138
lastTask = Task(on: MainActor.queue) {
@@ -136,7 +144,8 @@ struct ActorQueueTests {
136144
}
137145

138146
@TestingQueue
139-
@Test func test_mainThrowingTask_sendsEventsInOrder() async throws {
147+
@Test
148+
func mainThrowingTask_sendsEventsInOrder() async throws {
140149
var lastTask: Task<Void, Error>?
141150
(1...1_000).forEach { iteration in
142151
lastTask = Task(on: MainActor.queue) {
@@ -148,7 +157,8 @@ struct ActorQueueTests {
148157
try await #require(lastTask).value
149158
}
150159

151-
@Test func test_task_startsExecutionOfNextTaskAfterSuspension() async {
160+
@Test
161+
func task_startsExecutionOfNextTaskAfterSuspension() async {
152162
let systemUnderTest = ActorQueue<AsyncQueue.Semaphore>()
153163
let semaphore = AsyncQueue.Semaphore()
154164
systemUnderTest.adoptExecutionContext(of: semaphore)
@@ -165,7 +175,8 @@ struct ActorQueueTests {
165175
(_, _) = await (firstTask.value, secondTask.value)
166176
}
167177

168-
@Test func test_throwingTask_startsExecutionOfNextTaskAfterSuspension() async throws {
178+
@Test
179+
func throwingTask_startsExecutionOfNextTaskAfterSuspension() async throws {
169180
let systemUnderTest = ActorQueue<AsyncQueue.Semaphore>()
170181
let semaphore = AsyncQueue.Semaphore()
171182
systemUnderTest.adoptExecutionContext(of: semaphore)
@@ -184,7 +195,8 @@ struct ActorQueueTests {
184195
(_, _) = try await (firstTask.value, secondTask.value)
185196
}
186197

187-
@Test func test_task_allowsReentrancy() async {
198+
@Test
199+
func task_allowsReentrancy() async {
188200
await Task(on: systemUnderTest) { [systemUnderTest] counter in
189201
await Task(on: systemUnderTest) { counter in
190202
counter.incrementAndExpectCount(equals: 1)
@@ -193,7 +205,8 @@ struct ActorQueueTests {
193205
}.value
194206
}
195207

196-
@Test func test_throwingTask_allowsReentrancy() async throws {
208+
@Test
209+
func throwingTask_allowsReentrancy() async throws {
197210
try await Task(on: systemUnderTest) { [systemUnderTest] counter in
198211
try doWork()
199212
try await Task(on: systemUnderTest) { counter in
@@ -206,7 +219,8 @@ struct ActorQueueTests {
206219
}
207220

208221
@TestingQueue
209-
@Test func test_mainTask_allowsReentrancy() async {
222+
@Test
223+
func mainTask_allowsReentrancy() async {
210224
await Task(on: MainActor.queue) { [counter] in
211225
await Task(on: MainActor.queue) {
212226
await counter.incrementAndExpectCount(equals: 1)
@@ -216,7 +230,8 @@ struct ActorQueueTests {
216230
}
217231

218232
@TestingQueue
219-
@Test func test_mainThrowingTask_allowsReentrancy() async throws {
233+
@Test
234+
func mainThrowingTask_allowsReentrancy() async throws {
220235
try await Task(on: MainActor.queue) { [counter] in
221236
try doWork()
222237
try await Task(on: MainActor.queue) {
@@ -228,7 +243,8 @@ struct ActorQueueTests {
228243
}.value
229244
}
230245

231-
@Test func test_task_executesEnqueuedTasksAfterQueueIsDeallocated() async throws {
246+
@Test
247+
func task_executesEnqueuedTasksAfterQueueIsDeallocated() async throws {
232248
var systemUnderTest: ActorQueue<Counter>? = ActorQueue()
233249
systemUnderTest?.adoptExecutionContext(of: counter)
234250

@@ -249,7 +265,8 @@ struct ActorQueueTests {
249265
await expectation.fulfillment(withinSeconds: 30)
250266
}
251267

252-
@Test func test_throwingTask_executesEnqueuedTasksAfterQueueIsDeallocated() async throws {
268+
@Test
269+
func throwingTask_executesEnqueuedTasksAfterQueueIsDeallocated() async throws {
253270
var systemUnderTest: ActorQueue<Counter>? = ActorQueue()
254271
systemUnderTest?.adoptExecutionContext(of: counter)
255272

@@ -272,21 +289,24 @@ struct ActorQueueTests {
272289
await expectation.fulfillment(withinSeconds: 30)
273290
}
274291

275-
@Test func test_task_canReturn() async {
292+
@Test
293+
func task_canReturn() async {
276294
let expectedValue = UUID()
277295
let returnedValue = await Task(on: systemUnderTest) { _ in expectedValue }.value
278296
#expect(expectedValue == returnedValue)
279297
}
280298

281-
@Test func test_throwingTask_canReturn() async throws {
299+
@Test
300+
func throwingTask_canReturn() async throws {
282301
let expectedValue = UUID()
283302
@Sendable func generateValue() throws -> UUID {
284303
expectedValue
285304
}
286305
#expect(try await Task(on: systemUnderTest) { _ in try generateValue() }.value == expectedValue)
287306
}
288307

289-
@Test func test_throwingTask_canThrow() async {
308+
@Test
309+
func throwingTask_canThrow() async {
290310
struct TestError: Error, Equatable {
291311
private let identifier = UUID()
292312
}
@@ -298,7 +318,8 @@ struct ActorQueueTests {
298318
}
299319
}
300320

301-
@Test func test_mainThrowingTask_canThrow() async {
321+
@Test
322+
func mainThrowingTask_canThrow() async {
302323
struct TestError: Error, Equatable {
303324
private let identifier = UUID()
304325
}
@@ -310,15 +331,17 @@ struct ActorQueueTests {
310331
}
311332
}
312333

313-
@Test func test_mainTask_executesOnMainActor() async {
334+
@Test
335+
func mainTask_executesOnMainActor() async {
314336
@MainActor
315337
func executesOnMainActor() {}
316338
await Task(on: MainActor.queue) {
317339
executesOnMainActor()
318340
}.value
319341
}
320342

321-
@Test func test_mainThrowingTask_executesOnMainActor() async throws {
343+
@Test
344+
func mainThrowingTask_executesOnMainActor() async throws {
322345
@MainActor
323346
func executesOnMainActor() throws {}
324347
try await Task(on: MainActor.queue) {

Tests/AsyncQueueTests/ExpectationTests.swift

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ struct ExpectationTests {
2626

2727
// MARK: Behavior Tests
2828

29-
@Test func test_fulfill_triggersExpectation() async {
29+
@Test
30+
func fulfill_triggersExpectation() async {
3031
await confirmation { confirmation in
3132
let systemUnderTest = Expectation(
3233
expectedCount: 1,
@@ -39,7 +40,8 @@ struct ExpectationTests {
3940
}
4041
}
4142

42-
@Test func test_fulfill_triggersExpectationOnceWhenCalledTwiceAndExpectedCountIsTwo() async {
43+
@Test
44+
func fulfill_triggersExpectationOnceWhenCalledTwiceAndExpectedCountIsTwo() async {
4345
await confirmation { confirmation in
4446
let systemUnderTest = Expectation(
4547
expectedCount: 2,
@@ -53,7 +55,8 @@ struct ExpectationTests {
5355
}
5456
}
5557

56-
@Test func test_fulfill_triggersExpectationWhenExpectedCountIsZero() async {
58+
@Test
59+
func fulfill_triggersExpectationWhenExpectedCountIsZero() async {
5760
await confirmation { confirmation in
5861
let systemUnderTest = Expectation(
5962
expectedCount: 0,
@@ -66,13 +69,15 @@ struct ExpectationTests {
6669
}
6770
}
6871

69-
@Test func test_fulfillment_doesNotWaitIfAlreadyFulfilled() async {
72+
@Test
73+
func fulfillment_doesNotWaitIfAlreadyFulfilled() async {
7074
let systemUnderTest = Expectation(expectedCount: 0)
7175
await systemUnderTest.fulfillment(withinSeconds: 30)
7276
}
7377

7478
@MainActor // Global actor ensures Task ordering.
75-
@Test func test_fulfillment_waitsForFulfillment() async {
79+
@Test
80+
func fulfillment_waitsForFulfillment() async {
7681
let systemUnderTest = Expectation(expectedCount: 1)
7782
var hasFulfilled = false
7883
let wait = Task {
@@ -86,7 +91,8 @@ struct ExpectationTests {
8691
await wait.value
8792
}
8893

89-
@Test func test_fulfillment_triggersFalseExpectationWhenItTimesOut() async {
94+
@Test
95+
func fulfillment_triggersFalseExpectationWhenItTimesOut() async {
9096
await confirmation { confirmation in
9197
let systemUnderTest = Expectation(
9298
expectedCount: 1,

0 commit comments

Comments
 (0)