@@ -14,7 +14,7 @@ struct TestingTaskGroupTests {
14
14
@Test ( " Given tasks are scheduled at the same time, Then all the tasks are executed in order of enqueueing " )
15
15
func executeTasksInOrderOfEnqueueing( ) async throws {
16
16
let ( stream, continuation) = AsyncStream . makeStream ( of: Int . self)
17
- let operations = 0 ..< 5
17
+ let operations = 0 ..< 100
18
18
19
19
try await withTestingTaskGroup { group in
20
20
for operation in operations {
@@ -32,7 +32,7 @@ struct TestingTaskGroupTests {
32
32
@Test ( " Given tasks are scheduled at different times, Then all the tasks are executed in order of scheduling " )
33
33
func executeTasksInOrderOfScheduling( ) async throws {
34
34
let ( stream, continuation) = AsyncStream . makeStream ( of: Int . self)
35
- let source = 0 ..< 5
35
+ let source = 0 ..< 100
36
36
37
37
try await withTestingTaskGroup { group in
38
38
for (time, operation) in zip ( source, source) . reversed ( ) {
@@ -47,6 +47,26 @@ struct TestingTaskGroupTests {
47
47
await #expect( stream. collect ( ) == Array ( source) )
48
48
}
49
49
50
+ @Test ( " Given tasks with large time gaps, Then all the tasks are executed in order of scheduling " )
51
+ func executeTasksWithLargeTimeGaps( ) async throws {
52
+ let ( stream, continuation) = AsyncStream . makeStream ( of: Int . self)
53
+
54
+ try await withTestingTaskGroup { group in
55
+ group. addTask ( at: 10 ) {
56
+ continuation. yield ( 1 )
57
+ }
58
+ group. addTask ( at: 20 ) {
59
+ continuation. yield ( 2 )
60
+ }
61
+ group. addTask ( at: 50 ) {
62
+ continuation. yield ( 3 )
63
+ }
64
+ }
65
+
66
+ continuation. finish ( )
67
+
68
+ await #expect( stream. collect ( ) == [ 1 , 2 , 3 ] )
69
+ }
50
70
@Test ( " Given task suspended by dependency, When another task resolves dependency, Then dependent task resumes its work " )
51
71
func resumeDependentTaskWhenDependencyIsResolved( ) async throws {
52
72
let order = AsyncStream . makeStream ( of: Int . self)
0 commit comments