Skip to content

Commit dedaacb

Browse files
committed
Added test to verify RunLoop.run in poll mode returns in a reasonable time
1 parent dd402ba commit dedaacb

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

TestFoundation/TestRunLoop.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,16 @@ class TestRunLoop : XCTestCase {
6969

7070
XCTAssertLessThan(abs(timerTickInterval - expectedTimeInterval), 0.01)
7171
}
72+
73+
func test_runLoopPoll() {
74+
let runLoop = RunLoop.current
75+
76+
let startDate = Date()
77+
runLoop.run(until: Date())
78+
let endDate = Date()
79+
80+
XCTAssertLessThan(endDate.timeIntervalSince(startDate), 0.5)
81+
}
7282

7383
func test_commonModes() {
7484
let runLoop = RunLoop.current
@@ -123,6 +133,7 @@ class TestRunLoop : XCTestCase {
123133
// these tests do not work the same as Darwin https://bugs.swift.org/browse/SR-399
124134
// ("test_runLoopRunMode", test_runLoopRunMode),
125135
// ("test_runLoopLimitDate", test_runLoopLimitDate),
136+
("test_runLoopPoll", test_runLoopPoll),
126137
("test_addingRemovingPorts", test_addingRemovingPorts),
127138
]
128139
}

0 commit comments

Comments
 (0)