Skip to content

Commit 0178ef2

Browse files
committed
Add more declaration test cases
1 parent 62f67c9 commit 0178ef2

File tree

1 file changed

+108
-1
lines changed

1 file changed

+108
-1
lines changed

Tests/SwiftParserTest/DeclarationTests.swift

Lines changed: 108 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2551,7 +2551,7 @@ final class DeclarationTests: ParserTestCase {
25512551
)
25522552
}
25532553

2554-
func testFunctionDeclarationWithPlaceholder() {
2554+
func testDeclarationsWithPlaceholders() {
25552555
assertParse(
25562556
"""
25572557
func 1️⃣<#name#>(2️⃣<#parameters#>) -> 3️⃣<#return type#> {
@@ -2592,5 +2592,112 @@ final class DeclarationTests: ParserTestCase {
25922592
DiagnosticSpec(locationMarker: "4️⃣", message: "editor placeholder in source file"),
25932593
]
25942594
)
2595+
2596+
assertParse(
2597+
"""
2598+
func test1️⃣<#name#>() {
2599+
2️⃣<#function body#>
2600+
}
2601+
""",
2602+
substructure: FunctionDeclSyntax(
2603+
funcKeyword: .keyword(.func),
2604+
name: .identifier("name"),
2605+
signature: FunctionSignatureSyntax(
2606+
parameterClause: FunctionParameterClauseSyntax(
2607+
parameters: FunctionParameterListSyntax([])
2608+
),
2609+
returnClause: ReturnClauseSyntax(
2610+
type: IdentifierTypeSyntax(
2611+
name: .identifier("return type")
2612+
)
2613+
)
2614+
),
2615+
body: CodeBlockSyntax(
2616+
statements: CodeBlockItemListSyntax([
2617+
CodeBlockItemSyntax(
2618+
item: .expr(
2619+
ExprSyntax(
2620+
EditorPlaceholderExprSyntax(
2621+
placeholder: .identifier("function body")
2622+
)
2623+
)
2624+
)
2625+
)
2626+
])
2627+
)
2628+
),
2629+
diagnostics: [
2630+
DiagnosticSpec(locationMarker: "1️⃣", message: "editor placeholder in source file"),
2631+
DiagnosticSpec(locationMarker: "2️⃣", message: "editor placeholder in source file"),
2632+
]
2633+
)
2634+
2635+
assertParse(
2636+
"""
2637+
class 1️⃣<#name#>: 2️⃣<#super class#> {
2638+
3️⃣<#code#>
2639+
}
2640+
""",
2641+
diagnostics: [
2642+
DiagnosticSpec(locationMarker: "1️⃣", message: "editor placeholder in source file"),
2643+
DiagnosticSpec(locationMarker: "2️⃣", message: "editor placeholder in source file"),
2644+
DiagnosticSpec(locationMarker: "3️⃣", message: "editor placeholder in source file"),
2645+
]
2646+
)
2647+
2648+
assertParse(
2649+
"""
2650+
enum 1️⃣<#name#> {
2651+
case 2️⃣<#code#>
2652+
}
2653+
""",
2654+
diagnostics: [
2655+
DiagnosticSpec(locationMarker: "1️⃣", message: "editor placeholder in source file"),
2656+
DiagnosticSpec(locationMarker: "2️⃣", message: "editor placeholder in source file"),
2657+
]
2658+
)
2659+
2660+
assertParse(
2661+
"""
2662+
struct 1️⃣<#name#> {
2663+
2️⃣<#code#>
2664+
}
2665+
""",
2666+
diagnostics: [
2667+
DiagnosticSpec(locationMarker: "1️⃣", message: "editor placeholder in source file"),
2668+
DiagnosticSpec(locationMarker: "2️⃣", message: "editor placeholder in source file"),
2669+
]
2670+
)
2671+
2672+
assertParse(
2673+
"""
2674+
protocol 1️⃣<#name#> {
2675+
2️⃣<#code#>
2676+
}
2677+
""",
2678+
diagnostics: [
2679+
DiagnosticSpec(locationMarker: "1️⃣", message: "editor placeholder in source file"),
2680+
DiagnosticSpec(locationMarker: "2️⃣", message: "editor placeholder in source file"),
2681+
]
2682+
)
2683+
2684+
assertParse(
2685+
"""
2686+
import 1️⃣<#name#>
2687+
""",
2688+
diagnostics: [
2689+
DiagnosticSpec(locationMarker: "1️⃣", message: "editor placeholder in source file")
2690+
]
2691+
)
2692+
2693+
assertParse(
2694+
"""
2695+
typealias 1️⃣<#name#> = 2️⃣<#code#>
2696+
""",
2697+
diagnostics: [
2698+
DiagnosticSpec(locationMarker: "1️⃣", message: "editor placeholder in source file"),
2699+
DiagnosticSpec(locationMarker: "2️⃣", message: "editor placeholder in source file"),
2700+
]
2701+
)
25952702
}
25962703
}

0 commit comments

Comments
 (0)