Skip to content

[5.9] Display actual expanded source, not expected source #1918

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Sources/SwiftSyntaxMacrosTestSupport/Assertions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,8 @@ func assertDiagnostic<T: SyntaxProtocol>(
/// - Parameters:
/// - originalSource: The original source code, which is expected to contain
/// macros in various places (e.g., `#stringify(x + y)`).
/// - expandedSource: The source code that we expect to see after performing
/// macro expansion on the original source.
/// - expectedExpandedSource: The source code that we expect to see after
/// performing macro expansion on the original source.
/// - diagnostics:
/// - macros: The macros that should be expanded, provided as a dictionary
/// mapping macro names (e.g., `"stringify"`) to implementation types
Expand All @@ -265,7 +265,7 @@ func assertDiagnostic<T: SyntaxProtocol>(
/// - testFileName: The name of the test file name to use.
public func assertMacroExpansion(
_ originalSource: String,
expandedSource: String,
expandedSource expectedExpandedSource: String,
diagnostics: [DiagnosticSpec] = [],
macros: [String: Macro.Type],
testModuleName: String = "TestModule",
Expand Down Expand Up @@ -301,10 +301,10 @@ public func assertMacroExpansion(
let formattedSourceFile = expandedSourceFile.formatted(using: BasicFormat(indentationWidth: indentationWidth))
assertStringsEqualWithDiff(
formattedSourceFile.description.trimmingCharacters(in: .newlines),
expandedSource.trimmingCharacters(in: .newlines),
expectedExpandedSource.trimmingCharacters(in: .newlines),
additionalInfo: """
Actual expanded source:
\(expandedSource)
\(formattedSourceFile)
""",
file: file,
line: line
Expand Down