Files
SwiftLint/Tests/BuiltInRulesTests/TrailingClosureRuleTests.swift
Danny Mösch 15b285527a Separate built-in rule tests from framework tests (#5924)
* Short names for test modules
* Lint plugins and `Package.swift` in integration tests
* Simplify and merge file groups in Bazel
* Move common functions to `TestHelpers`
2024-12-30 12:26:46 +01:00

33 lines
1.3 KiB
Swift

@testable import SwiftLintBuiltInRules
import TestHelpers
final class TrailingClosureRuleTests: SwiftLintTestCase {
func testWithOnlySingleMutedParameterEnabled() {
let originalDescription = TrailingClosureRule.description
let description = originalDescription
.with(nonTriggeringExamples: originalDescription.nonTriggeringExamples + [
Example("foo.reduce(0, combine: { $0 + 1 })"),
Example("offsets.sorted(by: { $0.offset < $1.offset })"),
Example("foo.something(0, { $0 + 1 })"),
])
.with(triggeringExamples: [Example("foo.map(↓{ $0 + 1 })")])
.with(corrections: [
Example("foo.map(↓{ $0 + 1 })"):
Example("foo.map { $0 + 1 }"),
Example("f(↓{ g(↓{ 1 }) })"):
Example("f { g { 1 }}"),
Example("""
for n in list {
n.forEach(↓{ print($0) })
}
"""): Example("""
for n in list {
n.forEach { print($0) }
}
"""),
])
verifyRule(description, ruleConfiguration: ["only_single_muted_parameter": true])
}
}