mirror of
https://github.com/nicklockwood/SwiftFormat.git
synced 2026-05-17 10:30:35 +00:00
Fix hoistTry with XCTUnwrap
This commit is contained in:
@@ -13,7 +13,7 @@ public extension FormatRule {
|
||||
help: "Move inline `try` keyword(s) to start of expression.",
|
||||
options: ["throw-capturing"]
|
||||
) { formatter in
|
||||
let names = formatter.options.throwCapturing.union(["expect"])
|
||||
let names = formatter.options.throwCapturing.union(["expect", "XCTUnwrap"])
|
||||
formatter.forEachToken(where: {
|
||||
$0 == .startOfScope("(") || $0 == .startOfScope("[")
|
||||
}) { i, _ in
|
||||
|
||||
@@ -131,6 +131,13 @@ final class HoistTryTests: XCTestCase {
|
||||
testFormatting(for: input, rule: .hoistTry)
|
||||
}
|
||||
|
||||
func testNoHoistTryInsideXCTUnwrap() {
|
||||
let input = """
|
||||
let foo = try XCTUnwrap(try expression() as? Bar, message, file: file, line: line)
|
||||
"""
|
||||
testFormatting(for: input, rule: .hoistTry)
|
||||
}
|
||||
|
||||
func testNoMergeTrysInsideXCTAssert() {
|
||||
let input = """
|
||||
XCTAssertEqual(try foo(), try bar())
|
||||
|
||||
Reference in New Issue
Block a user