File tree Expand file tree Collapse file tree 2 files changed +50
-1
lines changed
Tests/SwiftSyntaxMacroExpansionTest Expand file tree Collapse file tree 2 files changed +50
-1
lines changed Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ import SwiftSyntaxMacros
2525import SwiftSyntaxMacrosTestSupport
2626import XCTest
2727
28- private struct ConstantOneGetter : AccessorMacro {
28+ struct ConstantOneGetter : AccessorMacro {
2929 static func expansion(
3030 of node: AttributeSyntax ,
3131 providingAccessorsOf declaration: some DeclSyntaxProtocol ,
Original file line number Diff line number Diff line change 1+ #if canImport(Testing)
2+ import Testing
3+ import SwiftSyntaxMacrosTestSupport
4+
5+ @Suite ( " Swift Testing Macro Expansion Tests " )
6+ struct SwiftTestingMacroExpansionTests {
7+ @Test ( " Test Happy Path " )
8+ func testHappyPathWorks( ) {
9+ assertMacroExpansion (
10+ """
11+ @constantOne
12+ var x: Int /*1*/ // hello
13+ """ ,
14+ expandedSource: """
15+ var x: Int { /*1*/ // hello
16+ get {
17+ return 1
18+ }
19+ }
20+ """ ,
21+ macros: [ " constantOne " : ConstantOneGetter . self] ,
22+ indentationWidth: . spaces( 2 )
23+ )
24+ }
25+
26+ @Test ( " Test Failure " )
27+ func failureReportedCorrectly( ) {
28+ withKnownIssue {
29+ assertMacroExpansion (
30+ """
31+ @constantOne
32+ var x: Int /*1*/ // hello
33+ """ ,
34+ expandedSource: """
35+ var x: Int { /*1*/ // hello
36+ get {
37+ return 1
38+ }
39+ }
40+ """ ,
41+ macros: [ " constantOne " : ConstantOneGetter . self] ,
42+ indentationWidth: . spaces( 4 )
43+ )
44+ } matching: { issue in
45+ issue. description. contains ( " Macro expansion did not produce the expected expanded source " )
46+ }
47+ }
48+ }
49+ #endif
You can’t perform that action at this time.
0 commit comments