mirror of
https://github.com/realm/SwiftLint.git
synced 2026-05-07 20:12:49 +00:00
15b285527a
* 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`
31 lines
1.0 KiB
Swift
31 lines
1.0 KiB
Swift
@testable import SwiftLintBuiltInRules
|
|
import TestHelpers
|
|
import XCTest
|
|
|
|
final class PreferKeyPathRuleTests: SwiftLintTestCase {
|
|
private static let extendedMode = ["restrict_to_standard_functions": false]
|
|
|
|
func testIdentityExpressionInSwift6() throws {
|
|
try XCTSkipIf(SwiftVersion.current < .six)
|
|
|
|
let description = PreferKeyPathRule.description
|
|
.with(nonTriggeringExamples: [
|
|
Example("f.filter { a in b }"),
|
|
Example("f.g { $1 }", configuration: Self.extendedMode),
|
|
])
|
|
.with(triggeringExamples: [
|
|
Example("f.compactMap ↓{ $0 }"),
|
|
Example("f.map ↓{ a in a }"),
|
|
Example("f.g { $0 }", configuration: Self.extendedMode),
|
|
])
|
|
.with(corrections: [
|
|
Example("f.map ↓{ $0 }"):
|
|
Example("f.map(\\.self)"),
|
|
Example("f.g { $0 }", configuration: Self.extendedMode):
|
|
Example("f.g(\\.self)"),
|
|
])
|
|
|
|
verifyRule(description)
|
|
}
|
|
}
|