Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add failing tests for sortTypealiases
Browse files Browse the repository at this point in the history
nicklockwood committed Nov 26, 2024
1 parent bb98ef2 commit 6f0d8db
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions Tests/Rules/SortTypealiasesTests.swift
Original file line number Diff line number Diff line change
@@ -175,4 +175,43 @@ class SortTypealiasesTests: XCTestCase {

testFormatting(for: input, output, rule: .sortTypealiases)
}

func testSortSingleLineTypealiasBeginningWithAny() {
let input = """
typealias Placeholders = any Foo & Bar & Quux & Baaz
"""

let output = """
typealias Placeholders = any Baaz & Bar & Foo & Quux
"""

testFormatting(for: input, output, rule: .sortTypealiases)
}

func testCollectionTypealiasWithArrayOfExistentialTypes() {
let input = "public typealias Parameters = [any Any & Sendable]"
testFormatting(for: input, rule: .sortTypealiases)
}

func testCollectionTypealiasWithDictionaryOfExistentialTypes() {
let input = "public typealias Parameters = [any Hashable & Sendable: any Any & Sendable]"
testFormatting(for: input, rule: .sortTypealiases)
}

func testCollectionTypealiasWithOptionalExistentialType() {
let input = "public typealias Parameters = (any Hashable & Sendable)?"
testFormatting(for: input, rule: .sortTypealiases)
}

func testCollectionTypealiasWithGenericExistentialType() {
let input = "public typealias Parameters = Result<any Hashable & Sendable, any Error & Sendable>"
testFormatting(for: input, rule: .sortTypealiases)
}

func testCollectionTypealiasWithExistentialClosureType() {
let input = """
public typealias Parameters = (any Hashable & Sendable, any Error & Sendable) -> any Equatable & Codable
"""
testFormatting(for: input, rule: .sortTypealiases)
}
}

0 comments on commit 6f0d8db

Please sign in to comment.