forked from realm/SwiftLint
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add configuration to discouraged_object_literal
Fixes realm#2439
- Loading branch information
1 parent
51caf3e
commit 1dfc2b6
Showing
6 changed files
with
60 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
Tests/SwiftLintFrameworkTests/DiscouragedObjectLiteralRuleTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import SwiftLintFramework | ||
import XCTest | ||
|
||
class DiscouragedObjectLiteralRuleTests: XCTestCase { | ||
func testWithDefaultConfiguration() { | ||
verifyRule(DiscouragedObjectLiteralRule.description) | ||
} | ||
|
||
func testWithImageLiteral() { | ||
let baseDescription = DiscouragedObjectLiteralRule.description | ||
let nonTriggeringExamples = baseDescription.nonTriggeringExamples + [ | ||
"let color = #colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)" | ||
] | ||
let triggeringExamples = [ | ||
"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 + [ | ||
"let image = #imageLiteral(resourceName: \"image.jpg\")" | ||
] | ||
let triggeringExamples = [ | ||
"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]) | ||
} | ||
} |