@@ -24,6 +24,16 @@ import SwiftSyntaxMacroExpansion
24
24
import SwiftSyntaxMacrosTestSupport
25
25
import XCTest
26
26
27
+ fileprivate struct NoOpMemberMacro : MemberMacro {
28
+ static func expansion(
29
+ of node: AttributeSyntax ,
30
+ providingMembersOf declaration: some DeclGroupSyntax ,
31
+ in context: some MacroExpansionContext
32
+ ) throws -> [ DeclSyntax ] {
33
+ return [ ]
34
+ }
35
+ }
36
+
27
37
final class MemberMacroTests : XCTestCase {
28
38
private let indentationWidth : Trivia = . spaces( 2 )
29
39
@@ -103,16 +113,6 @@ final class MemberMacroTests: XCTestCase {
103
113
}
104
114
105
115
func testCommentAroundeAttachedMacro( ) {
106
- struct TestMacro : MemberMacro {
107
- static func expansion(
108
- of node: AttributeSyntax ,
109
- providingMembersOf declaration: some DeclGroupSyntax ,
110
- in context: some MacroExpansionContext
111
- ) throws -> [ DeclSyntax ] {
112
- return [ ]
113
- }
114
- }
115
-
116
116
assertMacroExpansion (
117
117
"""
118
118
/// Some doc comment
@@ -128,7 +128,47 @@ final class MemberMacroTests: XCTestCase {
128
128
var value: Int
129
129
}
130
130
""" ,
131
- macros: [ " Test " : TestMacro . self] ,
131
+ macros: [ " Test " : NoOpMemberMacro . self] ,
132
+ indentationWidth: indentationWidth
133
+ )
134
+ }
135
+
136
+ func testStructVariableDeclWithMultipleBindings( ) {
137
+ assertMacroExpansion (
138
+ """
139
+ @Test
140
+ struct S {
141
+ var x: Int, y: Int
142
+ }
143
+ """ ,
144
+ expandedSource: """
145
+ struct S {
146
+ var x: Int, y: Int
147
+ }
148
+ """ ,
149
+ macros: [ " Test " : NoOpMemberMacro . self] ,
150
+ indentationWidth: indentationWidth
151
+ )
152
+ }
153
+
154
+ func testNestedStructVariableDeclWithMultipleBindings( ) {
155
+ assertMacroExpansion (
156
+ """
157
+ @Test
158
+ struct Q {
159
+ struct R {
160
+ var i: Int, j: Int
161
+ }
162
+ }
163
+ """ ,
164
+ expandedSource: """
165
+ struct Q {
166
+ struct R {
167
+ var i: Int, j: Int
168
+ }
169
+ }
170
+ """ ,
171
+ macros: [ " Test " : NoOpMemberMacro . self] ,
132
172
indentationWidth: indentationWidth
133
173
)
134
174
}
0 commit comments