mirror of
https://github.com/realm/SwiftLint.git
synced 2026-06-06 20:18:40 +00:00
6eedf5d73c
* Add private_only to prefixed_toplevel_constant This allows users to opt in to only validate top level constants have the given prefix if the constant is private or fileprivate.
27 lines
806 B
Swift
27 lines
806 B
Swift
@testable import SwiftLintFramework
|
|
import XCTest
|
|
|
|
final class PrefixedTopLevelConstantRuleTests: XCTestCase {
|
|
func testDefaultConfiguration() {
|
|
verifyRule(PrefixedTopLevelConstantRule.description)
|
|
}
|
|
|
|
func testPrivateOnly() {
|
|
let triggeringExamples = [
|
|
"private let ↓Foo = 20.0",
|
|
"fileprivate let ↓foo = 20.0"
|
|
]
|
|
let nonTriggeringExamples = [
|
|
"let Foo = 20.0",
|
|
"internal let Foo = \"Foo\"",
|
|
"public let Foo = 20.0"
|
|
]
|
|
|
|
let description = PrefixedTopLevelConstantRule.description
|
|
.with(triggeringExamples: triggeringExamples)
|
|
.with(nonTriggeringExamples: nonTriggeringExamples)
|
|
|
|
verifyRule(description, ruleConfiguration: ["only_private": true])
|
|
}
|
|
}
|