Skip to content

Commit 9b513ab

Browse files
authored
Merge pull request #1754 from ahoppen/ahoppen/assert-macro-expansion
In `assertMacroExpansion` trim newlines from expanded source
2 parents ccc812e + 52c48b5 commit 9b513ab

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

Sources/SwiftSyntaxMacrosTestSupport/Assertions.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,12 @@ public func assertMacroExpansion(
275275
let expandedSourceFile = origSourceFile.expand(macros: macros, in: context).formatted(using: BasicFormat(indentationWidth: indentationWidth))
276276

277277
assertStringsEqualWithDiff(
278-
expandedSourceFile.description,
279-
expandedSource,
278+
expandedSourceFile.description.trimmingCharacters(in: .newlines),
279+
expandedSource.trimmingCharacters(in: .newlines),
280+
additionalInfo: """
281+
Actual expanded source:
282+
\(expandedSource)
283+
""",
280284
file: file,
281285
line: line
282286
)

Tests/SwiftSyntaxMacrosTest/MacroSystemTests.swift

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,6 @@ final class MacroSystemTests: XCTestCase {
807807
}
808808
""",
809809
expandedSource: """
810-
811810
struct X {
812811
func f() {
813812
}
@@ -831,7 +830,6 @@ final class MacroSystemTests: XCTestCase {
831830
#bitwidthNumberedStructs("MyInt")
832831
""",
833832
expandedSource: """
834-
835833
struct MyInt8 {
836834
}
837835
struct MyInt16 {
@@ -853,7 +851,6 @@ final class MacroSystemTests: XCTestCase {
853851
var x: Int
854852
""",
855853
expandedSource: """
856-
857854
var x: Int {
858855
get {
859856
_x.wrappedValue
@@ -876,7 +873,6 @@ final class MacroSystemTests: XCTestCase {
876873
func f(a: Int, for b: String, _ value: Double) async -> String { }
877874
""",
878875
expandedSource: """
879-
880876
func f(a: Int, for b: String, _ value: Double) async -> String {
881877
}
882878
@@ -900,7 +896,6 @@ final class MacroSystemTests: XCTestCase {
900896
}
901897
""",
902898
expandedSource: """
903-
904899
struct S {
905900
var value: Int
906901
var _storage: Storage<Self>
@@ -928,7 +923,6 @@ final class MacroSystemTests: XCTestCase {
928923
}
929924
""",
930925
expandedSource: """
931-
932926
struct Point {
933927
@Wrapper
934928
var x: Int
@@ -973,7 +967,6 @@ final class MacroSystemTests: XCTestCase {
973967
}
974968
""",
975969
expandedSource: """
976-
977970
struct Point {
978971
@Wrapper
979972
var x: Int

0 commit comments

Comments
 (0)