@@ -28,6 +28,7 @@ class TestOperationQueue : XCTestCase {
28
28
( " test_MainQueueGetter " , test_MainQueueGetter) ,
29
29
( " test_CurrentQueueOnMainQueue " , test_CurrentQueueOnMainQueue) ,
30
30
( " test_CurrentQueueOnBackgroundQueue " , test_CurrentQueueOnBackgroundQueue) ,
31
+ ( " test_CurrentQueueOnBackgroundQueueWithSelfCancel " , test_CurrentQueueOnBackgroundQueueWithSelfCancel) ,
31
32
( " test_CurrentQueueWithCustomUnderlyingQueue " , test_CurrentQueueWithCustomUnderlyingQueue) ,
32
33
( " test_CurrentQueueWithUnderlyingQueueResetToNil " , test_CurrentQueueWithUnderlyingQueueResetToNil) ,
33
34
]
@@ -135,6 +136,20 @@ class TestOperationQueue : XCTestCase {
135
136
waitForExpectations ( timeout: 1 )
136
137
}
137
138
139
+ func test_CurrentQueueOnBackgroundQueueWithSelfCancel( ) {
140
+ let operationQueue = OperationQueue ( )
141
+ operationQueue. maxConcurrentOperationCount = 1
142
+ let expectation = self . expectation ( description: " Background execution " )
143
+ operationQueue. addOperation {
144
+ XCTAssertEqual ( operationQueue, OperationQueue . current)
145
+ expectation. fulfill ( )
146
+ // Canceling operation X from inside operation X should not cause the app to a crash
147
+ operationQueue. cancelAllOperations ( )
148
+ }
149
+
150
+ waitForExpectations ( timeout: 1 )
151
+ }
152
+
138
153
func test_CurrentQueueWithCustomUnderlyingQueue( ) {
139
154
let expectation = self . expectation ( description: " Background execution " )
140
155
0 commit comments