File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -39,11 +39,15 @@ final class TaskSchedulerTests: XCTestCase {
39
39
}
40
40
} ,
41
41
validate: { ( recordings: [ Set < TaskID > ] ) in
42
- // Check that all high-priority tasks get executed before the low-priority tasks
43
- let highPriorityRecordingSlice = recordings. dropLast ( while: {
44
- $0. isEmpty || $0. contains ( where: \. isLowPriority )
42
+ // Check that all high-priority tasks start executing before the low-priority tasks
43
+ let highPriorityRecordingSlice = recordings. prefix ( while: {
44
+ $0. isEmpty || $0. contains ( where: \. isHighPriority )
45
45
} )
46
- assertAllSatisfy ( highPriorityRecordingSlice) { !$0. contains ( where: \. isLowPriority) }
46
+ let taskIdsInHighPriorityRecordingSlice = Set ( highPriorityRecordingSlice. flatMap { $0 } )
47
+ XCTAssert (
48
+ taskIdsInHighPriorityRecordingSlice. isSuperset ( of: ( 0 ..< 10 ) . map ( TaskID . highPriority) ) ,
49
+ " Low priority task started executing before high-priority task. Recording: \( recordings) "
50
+ )
47
51
48
52
// Check that we never have more than the allowed number of low/high priority tasks, respectively
49
53
assertAllSatisfy ( recordings) { $0. count ( where: \. isLowPriority) <= lowPriorityTasks }
You can’t perform that action at this time.
0 commit comments