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`
35 lines
1.5 KiB
Swift
35 lines
1.5 KiB
Swift
@testable import SwiftLintBuiltInRules
|
|
import TestHelpers
|
|
|
|
final class DiscouragedObjectLiteralRuleTests: SwiftLintTestCase {
|
|
func testWithImageLiteral() {
|
|
let baseDescription = DiscouragedObjectLiteralRule.description
|
|
let nonTriggeringExamples = baseDescription.nonTriggeringExamples + [
|
|
Example("let color = #colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)")
|
|
]
|
|
let triggeringExamples = [
|
|
Example("let image = ↓#imageLiteral(resourceName: \"image.jpg\")")
|
|
]
|
|
|
|
let description = baseDescription.with(nonTriggeringExamples: nonTriggeringExamples,
|
|
triggeringExamples: triggeringExamples)
|
|
|
|
verifyRule(description, ruleConfiguration: ["image_literal": true, "color_literal": false])
|
|
}
|
|
|
|
func testWithColorLiteral() {
|
|
let baseDescription = DiscouragedObjectLiteralRule.description
|
|
let nonTriggeringExamples = baseDescription.nonTriggeringExamples + [
|
|
Example("let image = #imageLiteral(resourceName: \"image.jpg\")")
|
|
]
|
|
let triggeringExamples = [
|
|
Example("let color = ↓#colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)")
|
|
]
|
|
|
|
let description = baseDescription.with(nonTriggeringExamples: nonTriggeringExamples,
|
|
triggeringExamples: triggeringExamples)
|
|
|
|
verifyRule(description, ruleConfiguration: ["image_literal": false, "color_literal": true])
|
|
}
|
|
}
|