test: add php8.2 constants in traits test

This commit is contained in:
Laytan Laats 2023-03-25 16:11:37 +01:00
parent ce8b54eae1
commit 375ccd136d

View File

@ -399,3 +399,44 @@ class Bar {
suite.Run()
}
func TestConstantsInTraits(t *testing.T) {
suite := tester.NewParserDumpTestSuite(t)
suite.UsePHP8()
suite.Code = `<?php
trait Foo {
public const CONSTANT = 1;
}
`
suite.Expected = `&ast.Root{
Stmts: []ast.Vertex{
&ast.StmtTrait{
Name: &ast.Identifier{
Val: []byte("Foo"),
},
Stmts: []ast.Vertex{
&ast.StmtClassConstList{
Modifiers: []ast.Vertex{
&ast.Identifier{
Val: []byte("public"),
},
},
Consts: []ast.Vertex{
&ast.StmtConstant{
Name: &ast.Identifier{
Val: []byte("CONSTANT"),
},
Expr: &ast.ScalarLnumber{
Val: []byte("1"),
},
},
},
},
},
},
},
},`
suite.Run()
}