@@ -7,7 +7,6 @@ import SwiftSyntaxMacrosTestSupport
7
7
import XCTest
8
8
9
9
@testable import PluginCore
10
- @testable import MacroPlugin
11
10
12
11
final class CodableTests : XCTestCase {
13
12
@@ -310,6 +309,42 @@ final class CodableTests: XCTestCase {
310
309
}
311
310
}
312
311
312
+ #if canImport(MacroPlugin)
313
+ @testable import MacroPlugin
314
+
315
+ let allMacros : [ String : Macro . Type ] = [
316
+ " CodedAt " : MacroPlugin . CodedAt. self,
317
+ " CodedIn " : MacroPlugin . CodedIn. self,
318
+ " Default " : MacroPlugin . Default. self,
319
+ " CodedBy " : MacroPlugin . CodedBy. self,
320
+ " CodedAs " : MacroPlugin . CodedAs. self,
321
+ " ContentAt " : MacroPlugin . ContentAt. self,
322
+ " IgnoreCoding " : MacroPlugin . IgnoreCoding. self,
323
+ " IgnoreDecoding " : MacroPlugin . IgnoreDecoding. self,
324
+ " IgnoreEncoding " : MacroPlugin . IgnoreEncoding. self,
325
+ " Codable " : MacroPlugin . Codable. self,
326
+ " MemberInit " : MacroPlugin . MemberInit. self,
327
+ " CodingKeys " : MacroPlugin . CodingKeys. self,
328
+ " IgnoreCodingInitialized " : MacroPlugin . IgnoreCodingInitialized. self,
329
+ ]
330
+ #else
331
+ let allMacros : [ String : Macro . Type ] = [
332
+ " CodedAt " : CodedAt . self,
333
+ " CodedIn " : CodedIn . self,
334
+ " Default " : Default . self,
335
+ " CodedBy " : CodedBy . self,
336
+ " CodedAs " : CodedAs . self,
337
+ " ContentAt " : ContentAt . self,
338
+ " IgnoreCoding " : IgnoreCoding . self,
339
+ " IgnoreDecoding " : IgnoreDecoding . self,
340
+ " IgnoreEncoding " : IgnoreEncoding . self,
341
+ " Codable " : Codable . self,
342
+ " MemberInit " : MemberInit . self,
343
+ " CodingKeys " : CodingKeys . self,
344
+ " IgnoreCodingInitialized " : IgnoreCodingInitialized . self,
345
+ ]
346
+ #endif
347
+
313
348
func assertMacroExpansion(
314
349
_ originalSource: String ,
315
350
expandedSource: String ,
@@ -321,25 +356,10 @@ func assertMacroExpansion(
321
356
file: StaticString = #file,
322
357
line: UInt = #line
323
358
) {
324
- let macros : [ String : Macro . Type ] = [
325
- " CodedAt " : MacroPlugin . CodedAt. self,
326
- " CodedIn " : MacroPlugin . CodedIn. self,
327
- " Default " : MacroPlugin . Default. self,
328
- " CodedBy " : MacroPlugin . CodedBy. self,
329
- " CodedAs " : MacroPlugin . CodedAs. self,
330
- " ContentAt " : MacroPlugin . ContentAt. self,
331
- " IgnoreCoding " : MacroPlugin . IgnoreCoding. self,
332
- " IgnoreDecoding " : MacroPlugin . IgnoreDecoding. self,
333
- " IgnoreEncoding " : MacroPlugin . IgnoreEncoding. self,
334
- " Codable " : MacroPlugin . Codable. self,
335
- " MemberInit " : MacroPlugin . MemberInit. self,
336
- " CodingKeys " : MacroPlugin . CodingKeys. self,
337
- " IgnoreCodingInitialized " : MacroPlugin . IgnoreCodingInitialized. self,
338
- ]
339
359
assertMacroExpansion (
340
360
originalSource, expandedSource: expandedSource,
341
361
diagnostics: diagnostics,
342
- macroSpecs: macros . mapValues { value in
362
+ macroSpecs: allMacros . mapValues { value in
343
363
return MacroSpec ( type: value, conformances: conformances)
344
364
} ,
345
365
testModuleName: testModuleName, testFileName: testFileName,
0 commit comments