[refactoring] fix tests

This commit is contained in:
Vadym Slizov
2020-05-17 23:13:14 +03:00
parent 4971309b75
commit f4c15f4671
4 changed files with 63 additions and 19 deletions

View File

@@ -70,6 +70,12 @@ func (t *DFS) Traverse(n ast.Vertex) {
return
}
case *ast.ArgumentList:
if nn == nil {
return
}
if !t.visitor.EnterNode(nn) {
return
}
if nn.Arguments != nil {
t.visitor.Enter("Arguments", false)
for _, c := range nn.Arguments {
@@ -732,6 +738,12 @@ func (t *DFS) Traverse(n ast.Vertex) {
return
}
case *ast.StmtIf:
if nn == nil {
return
}
if !t.visitor.EnterNode(nn) {
return
}
if nn.Cond != nil {
t.visitor.Enter("Cond", true)
t.Traverse(nn.Cond)
@@ -2645,6 +2657,55 @@ func (t *DFS) Traverse(n ast.Vertex) {
if !t.visitor.EnterNode(nn) {
return
}
case *ast.NameName:
if nn == nil {
return
}
if !t.visitor.EnterNode(nn) {
return
}
if nn.Parts != nil {
t.visitor.Enter("Parts", false)
for _, c := range nn.Parts {
t.Traverse(c)
}
t.visitor.Leave("Parts", false)
}
case *ast.NameFullyQualified:
if nn == nil {
return
}
if !t.visitor.EnterNode(nn) {
return
}
if nn.Parts != nil {
t.visitor.Enter("Parts", false)
for _, c := range nn.Parts {
t.Traverse(c)
}
t.visitor.Leave("Parts", false)
}
case *ast.NameRelative:
if nn == nil {
return
}
if !t.visitor.EnterNode(nn) {
return
}
if nn.Parts != nil {
t.visitor.Enter("Parts", false)
for _, c := range nn.Parts {
t.Traverse(c)
}
t.visitor.Leave("Parts", false)
}
case *ast.NameNamePart:
if nn == nil {
return
}
if !t.visitor.EnterNode(nn) {
return
}
default:
panic("unexpected type of node")
}

View File

@@ -5,8 +5,8 @@ import (
"gotest.tools/assert"
"github.com/z7zmey/php-parser/errors"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/pkg/errors"
"github.com/z7zmey/php-parser/pkg/position"
)
func TestConstructor(t *testing.T) {