Closed
Description
Swift format can’t properly format multiple ifconfig statements in switch statements. To reproduce, paste the following as a unit test in the swift-format unit tests:
func testNestedPoundIfInSwitchStatement() {
let input =
"""
switch self {
#if os(iOS) || os(tvOS) || os(watchOS)
case .a:
return 40
#if os(iOS) || os(tvOS)
case .e:
return 30
#endif
#if os(iOS)
case .g:
return 2
#endif
#endif
default:
return nil
}
"""
var configuration = Configuration.forTesting
configuration.indentConditionalCompilationBlocks = false
assertPrettyPrintEqual(input: input, expected: input, linelength: 45, configuration: configuration)
}
The test fails with:
failed - Pretty-printed result was not what was expected - Actual output (+) differed from expected output (-):
switch self {
#if os(iOS) || os(tvOS) || os(watchOS)
case .a:
return 40
#if os(iOS) || os(tvOS)
case .e:
return 30
-#endif
-#if os(iOS)
+#endif#if os(iOS)
case .g:
return 2
#endif
#endif
default:
return nil
}
Metadata
Metadata
Assignees
Labels
No labels