Skip to content

Commit 8a71b5d

Browse files
buggmagnetpinkisemils
authored andcommitted
Add comments to explain a dummy function used in tests
1 parent 7108bfb commit 8a71b5d

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

ios/PacketTunnelCoreTests/TaskSleepTests.swift

+8-3
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ final class TaskSleepTests: XCTestCase {
3030
/// cancel a `DispatchSourceTimer` in a `Task` trying to call `resume` on its continuation handler more than once
3131
func testSuccessfulEventHandlerRemovesCancellation() async throws {
3232
for _ in 0 ... 20 {
33-
var task = recoveryTask()
33+
let task = recoveryTask()
3434
try await Task.sleep(duration: .milliseconds(10))
35-
task.doAnythingToSilenceAWarning()
35+
task.callDummyFunctionToForceConcurrencyWait()
3636
}
3737
}
3838

@@ -46,5 +46,10 @@ final class TaskSleepTests: XCTestCase {
4646
}
4747

4848
private extension AutoCancellingTask {
49-
func doAnythingToSilenceAWarning() {}
49+
/// This function is here to silence a warning about unused variables in `testSuccessfulEventHandlerRemovesCancellation`
50+
/// The following construct `_ = recoveryTask()` cannot be used as the resulting `AutoCancellingTask`
51+
/// would immediately get `deinit`ed, changing the test scenario.
52+
/// A dummy function is needed to make sure the task is not cancelled before concurrency is forced
53+
/// by having a call to `Task.sleep`
54+
func callDummyFunctionToForceConcurrencyWait() {}
5055
}

0 commit comments

Comments
 (0)