mirror of
https://github.com/nicklockwood/SwiftFormat.git
synced 2026-05-17 10:30:35 +00:00
Add more wrapArguments test cases (#2027)
This commit is contained in:
committed by
Cal Stephens
parent
042d86bbf6
commit
24334e162e
@@ -1795,6 +1795,37 @@ class WrapArgumentsTests: XCTestCase {
|
||||
testFormatting(for: input, output, rule: .wrapArguments, options: options)
|
||||
}
|
||||
|
||||
func testUnwrapEffectOnMultilineInit() {
|
||||
let input = """
|
||||
init(
|
||||
foo: String,
|
||||
bar: String
|
||||
)
|
||||
async throws
|
||||
{
|
||||
print(foo, bar)
|
||||
}
|
||||
"""
|
||||
|
||||
let output = """
|
||||
init(
|
||||
foo: String,
|
||||
bar: String
|
||||
) async throws {
|
||||
print(foo, bar)
|
||||
}
|
||||
"""
|
||||
|
||||
let options = FormatOptions(
|
||||
wrapArguments: .beforeFirst,
|
||||
closingParenPosition: .balanced,
|
||||
wrapReturnType: .never,
|
||||
wrapEffects: .never
|
||||
)
|
||||
|
||||
testFormatting(for: input, [output], rules: [.wrapArguments, .braces], options: options)
|
||||
}
|
||||
|
||||
func testWrapEffectOnMultilineProtocolRequirement() {
|
||||
let input = """
|
||||
protocol MyProtocol {
|
||||
@@ -1902,6 +1933,65 @@ class WrapArgumentsTests: XCTestCase {
|
||||
testFormatting(for: input, output, rule: .wrapArguments, options: options)
|
||||
}
|
||||
|
||||
func testUnwrapClosingBraceInVoidThrowingMethod() {
|
||||
let input = """
|
||||
func multilineFunction(
|
||||
foo: String,
|
||||
bar: String)
|
||||
async throws
|
||||
{
|
||||
print(foo, bar)
|
||||
}
|
||||
"""
|
||||
|
||||
let output = """
|
||||
func multilineFunction(
|
||||
foo: String,
|
||||
bar: String
|
||||
) async throws {
|
||||
print(foo, bar)
|
||||
}
|
||||
"""
|
||||
|
||||
let options = FormatOptions(
|
||||
wrapArguments: .beforeFirst,
|
||||
closingParenPosition: .balanced,
|
||||
wrapReturnType: .never,
|
||||
wrapEffects: .never
|
||||
)
|
||||
|
||||
testFormatting(for: input, [output], rules: [.wrapArguments, .braces], options: options)
|
||||
}
|
||||
|
||||
func testUnwrapClosingBraceInVoidNonThrowingMethod() {
|
||||
let input = """
|
||||
func multilineFunction(
|
||||
foo: String,
|
||||
bar: String)
|
||||
{
|
||||
print(foo, bar)
|
||||
}
|
||||
"""
|
||||
|
||||
let output = """
|
||||
func multilineFunction(
|
||||
foo: String,
|
||||
bar: String
|
||||
) {
|
||||
print(foo, bar)
|
||||
}
|
||||
"""
|
||||
|
||||
let options = FormatOptions(
|
||||
wrapArguments: .beforeFirst,
|
||||
closingParenPosition: .balanced,
|
||||
wrapReturnType: .never,
|
||||
wrapEffects: .never
|
||||
)
|
||||
|
||||
testFormatting(for: input, [output], rules: [.wrapArguments, .braces], options: options)
|
||||
}
|
||||
|
||||
func testFormatReturnTypeOnMultilineFunctionDeclarationWithBlockComment() {
|
||||
let input = """
|
||||
func multilineFunction(
|
||||
@@ -1954,6 +2044,31 @@ class WrapArgumentsTests: XCTestCase {
|
||||
testFormatting(for: input, output, rule: .wrapArguments, options: options)
|
||||
}
|
||||
|
||||
func testUnwrapReturnTypeOnMultilineSubscriptDeclaration() {
|
||||
let input = """
|
||||
subscript(
|
||||
foo _: String,
|
||||
bar _: String)
|
||||
-> String {}
|
||||
"""
|
||||
|
||||
let output = """
|
||||
subscript(
|
||||
foo _: String,
|
||||
bar _: String
|
||||
) -> String {}
|
||||
"""
|
||||
|
||||
let options = FormatOptions(
|
||||
wrapArguments: .beforeFirst,
|
||||
closingParenPosition: .balanced,
|
||||
wrapReturnType: .never,
|
||||
wrapEffects: .never
|
||||
)
|
||||
|
||||
testFormatting(for: input, output, rule: .wrapArguments, options: options)
|
||||
}
|
||||
|
||||
func testUnwrapBraceForReturnTypeOnMultilineFunctionDeclaration() {
|
||||
let input = """
|
||||
func multilineFunction(
|
||||
|
||||
Reference in New Issue
Block a user