From 35fd6f17477715c57f33d8886ffded37f0847090 Mon Sep 17 00:00:00 2001 From: Nick Lockwood Date: Fri, 28 Jul 2023 22:29:41 +0100 Subject: [PATCH] Move trailingSpace tests to more appropriate place --- Tests/RulesTests+Linebreaks.swift | 48 ------------------------------- Tests/RulesTests+Spacing.swift | 48 +++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 48 deletions(-) diff --git a/Tests/RulesTests+Linebreaks.swift b/Tests/RulesTests+Linebreaks.swift index 3c8243645..04a181de7 100644 --- a/Tests/RulesTests+Linebreaks.swift +++ b/Tests/RulesTests+Linebreaks.swift @@ -10,54 +10,6 @@ import XCTest @testable import SwiftFormat class LinebreakTests: RulesTests { - // MARK: - trailingSpace - - // truncateBlankLines = true - - func testTrailingSpace() { - let input = "foo \nbar" - let output = "foo\nbar" - testFormatting(for: input, output, rule: FormatRules.trailingSpace) - } - - func testTrailingSpaceAtEndOfFile() { - let input = "foo " - let output = "foo" - testFormatting(for: input, output, rule: FormatRules.trailingSpace) - } - - func testTrailingSpaceInMultilineComments() { - let input = "/* foo \n bar */" - let output = "/* foo\n bar */" - testFormatting(for: input, output, rule: FormatRules.trailingSpace) - } - - func testTrailingSpaceInSingleLineComments() { - let input = "// foo \n// bar " - let output = "// foo\n// bar" - testFormatting(for: input, output, rule: FormatRules.trailingSpace) - } - - func testTruncateBlankLine() { - let input = "foo {\n // bar\n \n // baz\n}" - let output = "foo {\n // bar\n\n // baz\n}" - testFormatting(for: input, output, rule: FormatRules.trailingSpace) - } - - func testTrailingSpaceInArray() { - let input = "let foo = [\n 1,\n \n 2,\n]" - let output = "let foo = [\n 1,\n\n 2,\n]" - testFormatting(for: input, output, rule: FormatRules.trailingSpace, exclude: ["redundantSelf"]) - } - - // truncateBlankLines = false - - func testNoTruncateBlankLine() { - let input = "foo {\n // bar\n \n // baz\n}" - let options = FormatOptions(truncateBlankLines: false) - testFormatting(for: input, rule: FormatRules.trailingSpace, options: options) - } - // MARK: - linebreaks func testCarriageReturn() { diff --git a/Tests/RulesTests+Spacing.swift b/Tests/RulesTests+Spacing.swift index 604a09a4b..25648992f 100644 --- a/Tests/RulesTests+Spacing.swift +++ b/Tests/RulesTests+Spacing.swift @@ -1354,6 +1354,54 @@ class SpacingTests: RulesTests { testFormatting(for: input, rule: FormatRules.consecutiveSpaces) } + // MARK: - trailingSpace + + // truncateBlankLines = true + + func testTrailingSpace() { + let input = "foo \nbar" + let output = "foo\nbar" + testFormatting(for: input, output, rule: FormatRules.trailingSpace) + } + + func testTrailingSpaceAtEndOfFile() { + let input = "foo " + let output = "foo" + testFormatting(for: input, output, rule: FormatRules.trailingSpace) + } + + func testTrailingSpaceInMultilineComments() { + let input = "/* foo \n bar */" + let output = "/* foo\n bar */" + testFormatting(for: input, output, rule: FormatRules.trailingSpace) + } + + func testTrailingSpaceInSingleLineComments() { + let input = "// foo \n// bar " + let output = "// foo\n// bar" + testFormatting(for: input, output, rule: FormatRules.trailingSpace) + } + + func testTruncateBlankLine() { + let input = "foo {\n // bar\n \n // baz\n}" + let output = "foo {\n // bar\n\n // baz\n}" + testFormatting(for: input, output, rule: FormatRules.trailingSpace) + } + + func testTrailingSpaceInArray() { + let input = "let foo = [\n 1,\n \n 2,\n]" + let output = "let foo = [\n 1,\n\n 2,\n]" + testFormatting(for: input, output, rule: FormatRules.trailingSpace, exclude: ["redundantSelf"]) + } + + // truncateBlankLines = false + + func testNoTruncateBlankLine() { + let input = "foo {\n // bar\n \n // baz\n}" + let options = FormatOptions(truncateBlankLines: false) + testFormatting(for: input, rule: FormatRules.trailingSpace, options: options) + } + // MARK: - emptyBraces func testLinebreaksRemovedInsideBraces() {