Files
SwiftLint/Tests/SwiftLintFrameworkTests/AttributesRuleTests.swift
T
JP Simard b83e0991b9 Remove all file headers
The MIT license doesn't require that all files be prepended with this
licensing or copyright information. Realm confirmed that they're ok with this
change. This will enable some companies to contribute to SwiftLint and the
date & authorship information will remain accessible via git source control.
2018-05-04 13:42:02 -07:00

58 lines
1.8 KiB
Swift

@testable import SwiftLintFramework
import XCTest
class AttributesRuleTests: XCTestCase {
func testAttributesWithDefaultConfiguration() {
// Test with default parameters
verifyRule(AttributesRule.description)
}
func testAttributesWithAlwaysOnSameLine() {
// Test with custom `always_on_same_line`
let nonTriggeringExamples = [
"@objc var x: String",
"@objc func foo()",
"@nonobjc\n func foo()",
"class Foo {\n" +
"@objc private var object: RLMWeakObjectHandle?\n" +
"@objc private var property: RLMProperty?\n" +
"}"
]
let triggeringExamples = [
"@objc\n ↓var x: String",
"@objc\n ↓func foo()",
"@nonobjc ↓func foo()"
]
let alwaysOnSameLineDescription = AttributesRule.description
.with(triggeringExamples: triggeringExamples)
.with(nonTriggeringExamples: nonTriggeringExamples)
verifyRule(alwaysOnSameLineDescription,
ruleConfiguration: ["always_on_same_line": ["@objc"]])
}
func testAttributesWithAlwaysOnLineAbove() {
// Test with custom `always_on_line_above`
let nonTriggeringExamples = [
"@objc\n var x: String",
"@objc\n func foo()",
"@nonobjc\n func foo()"
]
let triggeringExamples = [
"@objc ↓var x: String",
"@objc ↓func foo()",
"@nonobjc ↓func foo()"
]
let alwaysOnNewLineDescription = AttributesRule.description
.with(triggeringExamples: triggeringExamples)
.with(nonTriggeringExamples: nonTriggeringExamples)
verifyRule(alwaysOnNewLineDescription,
ruleConfiguration: ["always_on_line_above": ["@objc"]])
}
}