Repository: JuliaLang/julia
File: JuliaSyntax/test/syntax_graph.jl (Julia)

Code before:
        end
    end

    @testset "nested patterns" begin
        @test 1 === @stm st begin
            [K"call" _::K"Identifier" _::K"Identifier" [K"kw" _::K"Identifier" k1] [K"call" _::K"Identifier" [K"kw" _::K"Identifier" k2]]] -> 1
            [K"call" _::K"Identifier" _::K"Identifier" [K"kw" _::K"Identifier" k1] [K"call" _::K"Identifier" [K"kw" _ k2]]] -> 2
            [K"call" _::K"Identifier" _::K"Identifier" [K"kw" _ k1] [K"call" _ _]] -> 3
            [K"call" _::K"Identifier" _::K"Identifier" _ _ ] -> 4
            [K"call" _ _ _ _] -> 5
        end
        @test 1 === @stm st begin
            [K"call" _ _ [K"None" _::K"Identifier" k1] [K"None" _::K"Identifier" [K"None" [K"None"] k2]]] -> 5
            [K"call" _ _ [K"kw" _::K"Identifier" k1] [K"None" _::K"Identifier" [K"None" [K"None"] k2]]] -> 4
            [K"call" _ _ [K"kw" _::K"Identifier" k1] [K"call" _::K"Identifier" [K"None" [K"None"] k2]]] -> 3
            [K"call" _ _ [K"kw" _::K"Identifier" k1] [K"call" _::K"Identifier" [K"kw" [K"None"] k2]]] -> 2
            [K"call" _ _ [K"kw" _::K"Identifier" k1] [K"call" _::K"Identifier" [K"kw" _::K"Identifier" k2]]] -> 1
        end
        @test 1 === @stm st begin
            [K"call" _ _ [K"kw" _::K"Identifier" k1] [K"call" _::K"Identifier" [K"kw" _::K"Identifier" k2] bad]] -> 4
            [K"call" _ _ [K"kw" _::K"Identifier" k1] [K"call" _::K"Identifier" [K"kw" _::K"Identifier" k2 bad]]] -> 3
            [K"call" _ _ [K"kw" _::K"Identifier" k1] [K"call" _::K"Identifier" [K"kw" [K"Identifier" bad] k2]]] -> 2
            [K"call" _ _ [K"kw" _::K"Identifier" k1] [K"call" _::K"Identifier" [K"kw" _::K"Identifier" k2]]] -> 1
        end
        @test @stm st begin
            [K"call" x::K"Identifier" _ _ _] -> x === st[1]
        end
        @test @stm st begin
            [K"call" _ _ [K"kw" x::K"Identifier" _] _] -> x === st[3][1]
        end
    end

    @testset "vcat form (newlines in pattern)" begin
        @test @stm st begin
            [K"call"
             f
             a
             b
             c] -> true
        end
        @test @stm st begin
            [K"call"
             f a b c] -> true
        end
        @test @stm st begin
            [K"call"


             f a b c] -> true
        end
        @test @stm st begin

Review comment (suggestion):
Oh, this wasn't what I had in mind. My thought was to copy the same meaning that `@ast` uses so that we have

```suggestion
            [K"call" x::K"Identifier" _ _ _] -> x == "foo"
```

I don't think the `x::K"blah"` syntax is fitting if we want to get the actual node.

(I do think it would be useful to have syntax for "match a node of this kind regardless of its children". But I didn't want to make this PR more complicated.)

Code after:
            [K"call" _ _ [K"None" [K"Identifier"] k1] [K"None" [K"Identifier"] [K"None" [K"None"] k2]]] -> 5
            [K"call" _ _ [K"kw" [K"Identifier"] k1] [K"None" [K"Identifier"] [K"None" [K"None"] k2]]] -> 4
            [K"call" _ _ [K"kw" [K"Identifier"] k1] [K"call" [K"Identifier"] [K"None" [K"None"] k2]]] -> 3
            [K"call" _ _ [K"kw" [K"Identifier"] k1] [K"call" [K"Identifier"] [K"kw" [K"None"] k2]]] -> 2
            [K"call" _ _ [K"kw" [K"Identifier"] k1] [K"call" [K"Identifier"] [K"kw" [K"Identifier"] k2]]] -> 1
        end
        @test 1 === @stm st begin
            [K"call" _ _ [K"kw" [K"Identifier"] k1] [K"call" [K"Identifier"] [K"kw" [K"Identifier"] k2] bad]] -> 4
            [K"call" _ _ [K"kw" [K"Identifier"] k1] [K"call" [K"Identifier"] [K"kw" [K"Identifier"] k2 bad]]] -> 3
            [K"call" _ _ [K"kw" [K"Identifier"] k1] [K"call" [K"Identifier"] [K"kw" [K"Identifier" bad] k2]]] -> 2
            [K"call" _ _ [K"kw" [K"Identifier"] k1] [K"call" [K"Identifier"] [K"kw" [K"Identifier"] k2]]] -> 1
        end
    end

    @testset "vcat form (newlines in pattern)" begin
        @test @stm st begin
            [K"call"
             f
             a
             b
             c] -> true
        end
        @test @stm st begin
            [K"call"
             f a b c] -> true
        end
        @test @stm st begin
            [K"call"


             f a b c] -> true
        end
        @test @stm st begin
            [K"call"
             [K"Identifier"] [K"Identifier"]
             [K"kw" [K"Identifier"] k1]
             [K"call"
              [K"Identifier"]
              [K"kw"
               [K"Identifier"]
               k2]]] -> true
        end
    end

    @testset "SyntaxList splat matching" begin
        # trailing splat
        @test @stm st begin
            [K"call" f _...] -> true
        end
        @test @stm st begin
            [K"call" f args...] -> kind(f) === K"Identifier"