[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

1
go.mod
View File

@ -7,6 +7,5 @@ require (
github.com/pkg/errors v0.9.1 // indirect github.com/pkg/errors v0.9.1 // indirect
github.com/pkg/profile v1.4.0 github.com/pkg/profile v1.4.0
github.com/yookoala/realpath v1.0.0 github.com/yookoala/realpath v1.0.0
golang.org/x/tools v0.0.0-20200308013534-11ec41452d41 // indirect
gotest.tools v2.2.0+incompatible gotest.tools v2.2.0+incompatible
) )

16
go.sum
View File

@ -6,22 +6,6 @@ github.com/pkg/profile v1.4.0 h1:uCmaf4vVbWAOZz36k1hrQD7ijGRzLwaME8Am/7a4jZI=
github.com/pkg/profile v1.4.0/go.mod h1:NWz/XGvpEW1FyYQ7fCx4dqYBLlfTcE+A9FLAkNKqjFE= github.com/pkg/profile v1.4.0/go.mod h1:NWz/XGvpEW1FyYQ7fCx4dqYBLlfTcE+A9FLAkNKqjFE=
github.com/yookoala/realpath v1.0.0 h1:7OA9pj4FZd+oZDsyvXWQvjn5oBdcHRTV44PpdMSuImQ= github.com/yookoala/realpath v1.0.0 h1:7OA9pj4FZd+oZDsyvXWQvjn5oBdcHRTV44PpdMSuImQ=
github.com/yookoala/realpath v1.0.0/go.mod h1:gJJMA9wuX7AcqLy1+ffPatSCySA1FQ2S8Ya9AIoYBpE= github.com/yookoala/realpath v1.0.0/go.mod h1:gJJMA9wuX7AcqLy1+ffPatSCySA1FQ2S8Ya9AIoYBpE=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200308013534-11ec41452d41 h1:9Di9iYgOt9ThCipBxChBVhgNipDoE5mxO84rQV7D0FE=
golang.org/x/tools v0.0.0-20200308013534-11ec41452d41/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo=

View File

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

View File

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