@@ -15,6 +15,7 @@ class TestOperationQueue : XCTestCase {
15
15
( " test_OperationPriorities " , test_OperationPriorities) ,
16
16
( " test_OperationCount " , test_OperationCount) ,
17
17
( " test_AsyncOperation " , test_AsyncOperation) ,
18
+ ( " test_SyncOperationWithoutAQueue " , test_SyncOperationWithoutAQueue) ,
18
19
( " test_isExecutingWorks " , test_isExecutingWorks) ,
19
20
( " test_MainQueueGetter " , test_MainQueueGetter) ,
20
21
( " test_CancelOneOperation " , test_CancelOneOperation) ,
@@ -104,6 +105,18 @@ class TestOperationQueue : XCTestCase {
104
105
XCTAssertTrue ( operation. isFinished)
105
106
}
106
107
108
+ func test_SyncOperationWithoutAQueue( ) {
109
+ let operation = SyncOperation ( )
110
+ XCTAssertFalse ( operation. isExecuting)
111
+ XCTAssertFalse ( operation. isFinished)
112
+
113
+ operation. start ( )
114
+
115
+ XCTAssertFalse ( operation. isExecuting)
116
+ XCTAssertTrue ( operation. isFinished)
117
+ XCTAssertTrue ( operation. hasRun)
118
+ }
119
+
107
120
func test_MainQueueGetter( ) {
108
121
XCTAssertTrue ( OperationQueue . main === OperationQueue . main)
109
122
@@ -330,3 +343,14 @@ class AsyncOperation: Operation {
330
343
}
331
344
332
345
}
346
+
347
+ class SyncOperation : Operation {
348
+
349
+ var hasRun = false
350
+
351
+ override func main( ) {
352
+ Thread . sleep ( forTimeInterval: 1 )
353
+ hasRun = true
354
+ }
355
+
356
+ }
0 commit comments