1- @testable import SwiftLintBuiltInRules
21import TestHelpers
2+ import Testing
3+
4+ @testable import SwiftLintBuiltInRules
35
4- final class AttributesRuleTests : SwiftLintTestCase {
5- func testAttributesWithAlwaysOnSameLine( ) {
6+ @Suite ( . rulesRegistered)
7+ struct AttributesRuleTests {
8+ @Test
9+ func attributesWithAlwaysOnSameLine( ) {
610 // Test with custom `always_on_same_line`
711 let nonTriggeringExamples = [
812 Example ( " @objc var x: String " ) ,
913 Example ( " @objc func foo() " ) ,
1014 Example ( " @nonobjc \n func foo() " ) ,
11- Example ( """
12- class Foo {
13- @objc private var object: RLMWeakObjectHandle?
14- @objc private var property: RLMProperty?
15- }
16- """ ) ,
17- Example ( """
18- @objc(XYZFoo) class Foo: NSObject {}
19- """ ) ,
15+ Example (
16+ """
17+ class Foo {
18+ @objc private var object: RLMWeakObjectHandle?
19+ @objc private var property: RLMProperty?
20+ }
21+ """ ) ,
22+ Example (
23+ """
24+ @objc(XYZFoo) class Foo: NSObject {}
25+ """ ) ,
2026 ]
2127 let triggeringExamples = [
2228 Example ( " @objc \n ↓var x: String " ) ,
@@ -28,11 +34,13 @@ final class AttributesRuleTests: SwiftLintTestCase {
2834 . with ( triggeringExamples: triggeringExamples)
2935 . with ( nonTriggeringExamples: nonTriggeringExamples)
3036
31- verifyRule ( alwaysOnSameLineDescription,
32- ruleConfiguration: [ " always_on_same_line " : [ " @objc " ] ] )
37+ verifyRule (
38+ alwaysOnSameLineDescription,
39+ ruleConfiguration: [ " always_on_same_line " : [ " @objc " ] ] )
3340 }
3441
35- func testAttributesWithAlwaysOnLineAbove( ) {
42+ @Test
43+ func attributesWithAlwaysOnLineAbove( ) {
3644 // Test with custom `always_on_line_above`
3745 let nonTriggeringExamples = [
3846 Example ( " @objc \n var x: String " ) ,
@@ -49,43 +57,49 @@ final class AttributesRuleTests: SwiftLintTestCase {
4957 . with ( triggeringExamples: triggeringExamples)
5058 . with ( nonTriggeringExamples: nonTriggeringExamples)
5159
52- verifyRule ( alwaysOnNewLineDescription,
53- ruleConfiguration: [ " always_on_line_above " : [ " @objc " ] ] )
60+ verifyRule (
61+ alwaysOnNewLineDescription,
62+ ruleConfiguration: [ " always_on_line_above " : [ " @objc " ] ] )
5463 }
5564
56- func testAttributesWithAttributesOnLineAboveButOnOtherDeclaration( ) {
65+ @Test
66+ func attributesWithAttributesOnLineAboveButOnOtherDeclaration( ) {
5767 let nonTriggeringExamples = [
58- Example ( """
59- @IBDesignable open class TagListView: UIView {
60- @IBInspectable open dynamic var textColor: UIColor = UIColor.white {
61- didSet {}
68+ Example (
69+ """
70+ @IBDesignable open class TagListView: UIView {
71+ @IBInspectable open dynamic var textColor: UIColor = UIColor.white {
72+ didSet {}
73+ }
6274 }
63- }
64- """ ) ,
65- Example ( """
66- @objc public protocol TagListViewDelegate {
67- @objc optional func tagDidSelect(_ title: String, sender: TagListView)
68- @objc optional func tagDidDeselect(_ title: String, sender: TagListView)
69- }
70- """ ) ,
75+ """ ) ,
76+ Example (
77+ """
78+ @objc public protocol TagListViewDelegate {
79+ @objc optional func tagDidSelect(_ title: String, sender: TagListView)
80+ @objc optional func tagDidDeselect(_ title: String, sender: TagListView)
81+ }
82+ """ ) ,
7183 ]
7284
7385 let triggeringExamples = [
74- Example ( """
75- @IBDesignable open class TagListView: UIView {
76- @IBInspectable
77- open dynamic ↓var textColor: UIColor = UIColor.white {
78- didSet {}
86+ Example (
87+ """
88+ @IBDesignable open class TagListView: UIView {
89+ @IBInspectable
90+ open dynamic ↓var textColor: UIColor = UIColor.white {
91+ didSet {}
92+ }
7993 }
80- }
81- """ ) ,
82- Example ( """
83- @objc public protocol TagListViewDelegate {
84- @objc
85- optional ↓func tagDidSelect(_ title: String, sender: TagListView)
86- @objc optional func tagDidDeselect(_ title: String, sender: TagListView)
87- }
88- """ ) ,
94+ """ ) ,
95+ Example (
96+ """
97+ @objc public protocol TagListViewDelegate {
98+ @objc
99+ optional ↓func tagDidSelect(_ title: String, sender: TagListView)
100+ @objc optional func tagDidDeselect(_ title: String, sender: TagListView)
101+ }
102+ """ ) ,
89103 ]
90104
91105 let alwaysOnNewLineDescription = AttributesRule . description
@@ -102,26 +116,29 @@ final class AttributesRuleTests: SwiftLintTestCase {
102116 )
103117 }
104118
105- func testAttributesWithArgumentsAlwaysOnLineAboveFalse( ) {
119+ @Test
120+ func attributesWithArgumentsAlwaysOnLineAboveFalse( ) {
106121 let nonTriggeringExamples = [
107122 Example ( " @Environment( \\ .presentationMode) private var presentationMode " )
108123 ]
109124 let triggeringExamples = [
110125 Example ( """
111- @Environment( \\ .presentationMode)
112- private ↓var presentationMode
113- """ ) ,
126+ @Environment( \\ .presentationMode)
127+ private ↓var presentationMode
128+ """ ) ,
114129 ]
115130
116131 let argumentsAlwaysOnLineDescription = AttributesRule . description
117132 . with ( triggeringExamples: triggeringExamples)
118133 . with ( nonTriggeringExamples: nonTriggeringExamples)
119134
120- verifyRule ( argumentsAlwaysOnLineDescription,
121- ruleConfiguration: [ " attributes_with_arguments_always_on_line_above " : false ] )
135+ verifyRule (
136+ argumentsAlwaysOnLineDescription,
137+ ruleConfiguration: [ " attributes_with_arguments_always_on_line_above " : false ] )
122138 }
123139
124- func testAttributesWithArgumentsAlwaysOnLineAboveTrue( ) {
140+ @Test
141+ func attributesWithArgumentsAlwaysOnLineAboveTrue( ) {
125142 let nonTriggeringExamples = [
126143 Example ( " @Environment( \\ .presentationMode) \n private var presentationMode " )
127144 ]
@@ -133,7 +150,8 @@ final class AttributesRuleTests: SwiftLintTestCase {
133150 . with ( triggeringExamples: triggeringExamples)
134151 . with ( nonTriggeringExamples: nonTriggeringExamples)
135152
136- verifyRule ( argumentsAlwaysOnLineDescription,
137- ruleConfiguration: [ " attributes_with_arguments_always_on_line_above " : true ] )
153+ verifyRule (
154+ argumentsAlwaysOnLineDescription,
155+ ruleConfiguration: [ " attributes_with_arguments_always_on_line_above " : true ] )
138156 }
139157}
0 commit comments