Skip to content

Commit 1ae73f4

Browse files
committed
run SwiftFormat
1 parent 5383369 commit 1ae73f4

File tree

1 file changed

+42
-42
lines changed

1 file changed

+42
-42
lines changed

Tests/AsyncHTTPClientTests/XCTest+AsyncAwait.swift

+42-42
Original file line numberDiff line numberDiff line change
@@ -27,53 +27,53 @@
2727
* limitations under the License.
2828
*/
2929
#if compiler(>=5.5)
30-
import XCTest
30+
import XCTest
3131

32-
extension XCTestCase {
33-
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
34-
/// Cross-platform XCTest support for async-await tests.
35-
///
36-
/// Currently the Linux implementation of XCTest doesn't have async-await support.
37-
/// Until it does, we make use of this shim which uses a detached `Task` along with
38-
/// `XCTest.wait(for:timeout:)` to wrap the operation.
39-
///
40-
/// - NOTE: Support for Linux is tracked by https://bugs.swift.org/browse/SR-14403.
41-
/// - NOTE: Implementation currently in progress: https://github.com/apple/swift-corelibs-xctest/pull/326
42-
func XCTAsyncTest(
43-
expectationDescription: String = "Async operation",
44-
timeout: TimeInterval = 30,
45-
file: StaticString = #filePath,
46-
line: UInt = #line,
47-
function: StaticString = #function,
48-
operation: @escaping () async throws -> Void
49-
) {
50-
let expectation = self.expectation(description: expectationDescription)
51-
Task {
52-
do {
53-
try await operation()
54-
} catch {
55-
XCTFail("Error thrown while executing \(function): \(error)", file: file, line: line)
56-
Thread.callStackSymbols.forEach { print($0) }
57-
}
58-
expectation.fulfill()
32+
extension XCTestCase {
33+
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
34+
/// Cross-platform XCTest support for async-await tests.
35+
///
36+
/// Currently the Linux implementation of XCTest doesn't have async-await support.
37+
/// Until it does, we make use of this shim which uses a detached `Task` along with
38+
/// `XCTest.wait(for:timeout:)` to wrap the operation.
39+
///
40+
/// - NOTE: Support for Linux is tracked by https://bugs.swift.org/browse/SR-14403.
41+
/// - NOTE: Implementation currently in progress: https://github.com/apple/swift-corelibs-xctest/pull/326
42+
func XCTAsyncTest(
43+
expectationDescription: String = "Async operation",
44+
timeout: TimeInterval = 30,
45+
file: StaticString = #filePath,
46+
line: UInt = #line,
47+
function: StaticString = #function,
48+
operation: @escaping () async throws -> Void
49+
) {
50+
let expectation = self.expectation(description: expectationDescription)
51+
Task {
52+
do {
53+
try await operation()
54+
} catch {
55+
XCTFail("Error thrown while executing \(function): \(error)", file: file, line: line)
56+
Thread.callStackSymbols.forEach { print($0) }
5957
}
60-
self.wait(for: [expectation], timeout: timeout)
58+
expectation.fulfill()
6159
}
60+
self.wait(for: [expectation], timeout: timeout)
6261
}
62+
}
6363

64-
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
65-
internal func XCTAssertThrowsError<T>(
66-
_ expression: @autoclosure () async throws -> T,
67-
verify: (Error) -> Void = { _ in },
68-
file: StaticString = #file,
69-
line: UInt = #line
70-
) async {
71-
do {
72-
_ = try await expression()
73-
XCTFail("Expression did not throw error", file: file, line: line)
74-
} catch {
75-
verify(error)
76-
}
64+
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
65+
internal func XCTAssertThrowsError<T>(
66+
_ expression: @autoclosure () async throws -> T,
67+
verify: (Error) -> Void = { _ in },
68+
file: StaticString = #file,
69+
line: UInt = #line
70+
) async {
71+
do {
72+
_ = try await expression()
73+
XCTFail("Expression did not throw error", file: file, line: line)
74+
} catch {
75+
verify(error)
7776
}
77+
}
7878

7979
#endif // compiler(>=5.5)

0 commit comments

Comments
 (0)