Skip to content

Test that the fixups are generated if display name is empty #1267

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
Aug 14, 2025
Merged
Changes from 1 commit
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
65 changes: 57 additions & 8 deletions Tests/TestingMacrosTests/TestDeclarationMacroTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,6 @@ struct TestDeclarationMacroTests {
"Attribute 'Test' cannot be applied to a function within structure 'S' because its conformance to 'Escapable' has been suppressed",
"struct S: ~(Escapable) { @Test func f() {} }":
"Attribute 'Test' cannot be applied to a function within structure 'S' because its conformance to 'Escapable' has been suppressed",

// empty display name string literal
#"@Test("") func f() {}"#:
"Attribute 'Test' specifies an empty display name for this function",
##"@Test(#""#) func f() {}"##:
"Attribute 'Test' specifies an empty display name for this function",
#"@Suite("") struct S {}"#:
"Attribute 'Suite' specifies an empty display name for this structure",
]
)
func apiMisuseErrors(input: String, expectedMessage: String) throws {
Expand Down Expand Up @@ -241,6 +233,63 @@ struct TestDeclarationMacroTests {
),
]
),

// empty display name string literal
#"@Test("") func f() {}"#:
(
message: "Attribute 'Test' specifies an empty display name for this function",
fixIts: [
ExpectedFixIt(
message: "Remove display name argument",
changes: [
.replace(oldSourceCode: #""""#, newSourceCode: "")
]),
ExpectedFixIt(
message: "Add display name",
changes: [
.replace(
oldSourceCode: #""""#,
newSourceCode: #""\#(EditorPlaceholderExprSyntax("display name"))""#)
])
]
),
##"@Test(#""#) func f() {}"##:
(
message: "Attribute 'Test' specifies an empty display name for this function",
fixIts: [
ExpectedFixIt(
message: "Remove display name argument",
changes: [
.replace(oldSourceCode: ##"#""#"##, newSourceCode: "")
]),
ExpectedFixIt(
message: "Add display name",
changes: [
.replace(
oldSourceCode: ##"#""#"##,
newSourceCode: #""\#(EditorPlaceholderExprSyntax("display name"))""#)
])
]
),
#"@Suite("") struct S {}"#:
(
message:
"Attribute 'Suite' specifies an empty display name for this structure",
fixIts: [
ExpectedFixIt(
message: "Remove display name argument",
changes: [
.replace(oldSourceCode: #""""#, newSourceCode: "")
]),
ExpectedFixIt(
message: "Add display name",
changes: [
.replace(
oldSourceCode: #""""#,
newSourceCode: #""\#(EditorPlaceholderExprSyntax("display name"))""#)
])
]
)
]
}

Expand Down