Skip to content
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
64 changes: 56 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,62 @@ 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