Skip to content

Commit

Permalink
Move trailingSpace tests to more appropriate place
Browse files Browse the repository at this point in the history
  • Loading branch information
nicklockwood committed Aug 5, 2023
1 parent b4f96ac commit 35fd6f1
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 48 deletions.
48 changes: 0 additions & 48 deletions Tests/RulesTests+Linebreaks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
48 changes: 48 additions & 0 deletions Tests/RulesTests+Spacing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 35fd6f1

Please sign in to comment.