@@ -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) ,
@@ -105,6 +106,18 @@ class TestOperationQueue : XCTestCase {
105
106
XCTAssertTrue ( operation. isFinished)
106
107
}
107
108
109
+ func test_SyncOperationWithoutAQueue( ) {
110
+ let operation = SyncOperation ( )
111
+ XCTAssertFalse ( operation. isExecuting)
112
+ XCTAssertFalse ( operation. isFinished)
113
+
114
+ operation. start ( )
115
+
116
+ XCTAssertFalse ( operation. isExecuting)
117
+ XCTAssertTrue ( operation. isFinished)
118
+ XCTAssertTrue ( operation. hasRun)
119
+ }
120
+
108
121
func test_MainQueueGetter( ) {
109
122
XCTAssertTrue ( OperationQueue . main === OperationQueue . main)
110
123
@@ -345,3 +358,14 @@ class AsyncOperation: Operation {
345
358
}
346
359
347
360
}
361
+
362
+ class SyncOperation : Operation {
363
+
364
+ var hasRun = false
365
+
366
+ override func main( ) {
367
+ Thread . sleep ( forTimeInterval: 1 )
368
+ hasRun = true
369
+ }
370
+
371
+ }
0 commit comments