Skip to content

[5.9] Add a public function that can be used to test macro expansions #1586

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
Apr 26, 2023

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Apr 25, 2023

Cherry-pick #1550 to release/5.9


Testing macros should be as easy as possible and we should thus make the assertMacroExpansion function public.

While making the function public, I made the following changes:

  • Changed diagnosticMessages to expect DiagnsoticSpec similar to the parser tests. The only difference is that they take line and columns instead of location markers because the location markers have a slighgly high learning curve IMO.

Slightly unrelated, I also made the following changes:

  • Made a few minor improvements to SwiftParserTest/Assertions.swift
  • Fixed a bug in MacroApplication where the wrong syntax node was passed as the node parametertoaddDiagnostics`, leading to a highlight that was bigger than expected.

@ahoppen ahoppen requested a review from DougGregor as a code owner April 25, 2023 21:05
@ahoppen ahoppen changed the title Add a public function that can be used to test macro expansions [5.9] Add a public function that can be used to test macro expansions Apr 25, 2023
@ahoppen
Copy link
Member Author

ahoppen commented Apr 25, 2023

@swift-ci Please test

@ahoppen ahoppen force-pushed the ahoppen/5.9/assert-macro branch from 4f32783 to 6863ec2 Compare April 26, 2023 01:14
@ahoppen
Copy link
Member Author

ahoppen commented Apr 26, 2023

@swift-ci Please test

@ahoppen
Copy link
Member Author

ahoppen commented Apr 26, 2023

@swift-ci Please test Windows

1 similar comment
@ahoppen
Copy link
Member Author

ahoppen commented Apr 26, 2023

@swift-ci Please test Windows

ahoppen added 2 commits April 26, 2023 06:51
Testing macros should be as easy as possible and we should thus make the  `assertMacroExpansion` function public.

While making the function public, I made the following changes:
- Changed `diagnosticMessages` to expect `DiagnsoticSpec` similar to the parser tests. The only difference is that they take line and columns instead of location markers because the location markers have a slighgly high learning curve IMO.

Slightly unrelated, I also made the following changes:
- Made a few minor improvements to `SwiftParserTest/Assertions.swift`
- Fixed a bug in MacroApplication where the wrong syntax node was passed as the `node` parameter` to `addDiagnostics`, leading to a highlight that was bigger than expected.
@ahoppen ahoppen force-pushed the ahoppen/5.9/assert-macro branch from 6863ec2 to c7b75dd Compare April 26, 2023 13:52
@ahoppen
Copy link
Member Author

ahoppen commented Apr 26, 2023

@swift-ci Please test

@ahoppen
Copy link
Member Author

ahoppen commented Apr 26, 2023

@swift-ci Please test Windows

@ahoppen ahoppen merged commit ebe3885 into swiftlang:release/5.9 Apr 26, 2023
@ahoppen ahoppen deleted the ahoppen/5.9/assert-macro branch April 26, 2023 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants