1
1
import SwiftSyntaxMacros
2
2
import SwiftSyntaxMacrosTestSupport
3
- import Testing
3
+ import XCTest
4
4
5
5
// Macro implementations build for the host, so the corresponding module is not available when cross-compiling.
6
6
// Cross-compiled tests may still make use of the macro itself in end-to-end tests.
@@ -15,10 +15,9 @@ let testMacros: [String: Macro.Type] = [
15
15
let testMacros : [ String : Macro . Type ] = [ : ]
16
16
#endif
17
17
18
- @Suite ( . serialized)
19
- final class ObservableDefaultMacroTests {
20
- @Test ( . disabled( if: testMacros. isEmpty) )
18
+ final class ObservableDefaultMacroTests : XCTestCase {
21
19
func testExpansionWithMemberSyntax( ) throws {
20
+ #if canImport(DefaultsMacrosDeclarations)
22
21
assertMacroExpansion (
23
22
#"""
24
23
@Observable
@@ -49,10 +48,13 @@ final class ObservableDefaultMacroTests {
49
48
macros: testMacros,
50
49
indentationWidth: . tabs( 1 )
51
50
)
51
+ #else
52
+ throw XCTSkip ( " Macros are only supported when running tests for the host platform " )
53
+ #endif
52
54
}
53
55
54
- @Test ( . disabled( if: testMacros. isEmpty) )
55
56
func testExpansionWithDotSyntax( ) throws {
57
+ #if canImport(DefaultsMacrosDeclarations)
56
58
assertMacroExpansion (
57
59
#"""
58
60
@Observable
@@ -83,10 +85,13 @@ final class ObservableDefaultMacroTests {
83
85
macros: testMacros,
84
86
indentationWidth: . tabs( 1 )
85
87
)
88
+ #else
89
+ throw XCTSkip ( " Macros are only supported when running tests for the host platform " )
90
+ #endif
86
91
}
87
92
88
- @Test ( . disabled( if: testMacros. isEmpty) )
89
93
func testExpansionWithFunctionCall( ) throws {
94
+ #if canImport(DefaultsMacrosDeclarations)
90
95
assertMacroExpansion (
91
96
#"""
92
97
@Observable
@@ -117,10 +122,13 @@ final class ObservableDefaultMacroTests {
117
122
macros: testMacros,
118
123
indentationWidth: . tabs( 1 )
119
124
)
125
+ #else
126
+ throw XCTSkip ( " Macros are only supported when running tests for the host platform " )
127
+ #endif
120
128
}
121
129
122
- @Test ( . disabled( if: testMacros. isEmpty) )
123
130
func testExpansionWithProperty( ) throws {
131
+ #if canImport(DefaultsMacrosDeclarations)
124
132
assertMacroExpansion (
125
133
#"""
126
134
@Observable
@@ -151,5 +159,8 @@ final class ObservableDefaultMacroTests {
151
159
macros: testMacros,
152
160
indentationWidth: . tabs( 1 )
153
161
)
162
+ #else
163
+ throw XCTSkip ( " Macros are only supported when running tests for the host platform " )
164
+ #endif
154
165
}
155
166
}
0 commit comments