rename meta to freefloating; refactoring

This commit is contained in:
z7zmey
2019-02-13 22:18:07 +02:00
parent a7082117d9
commit b3800a2595
309 changed files with 9671 additions and 10115 deletions

View File

@@ -1,7 +1,7 @@
package binary
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// BitwiseAnd node
type BitwiseAnd struct {
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
FreeFloating freefloating.Collection
Position *position.Position
Left node.Node
Right node.Node
}
// NewBitwiseAnd node constructor
func NewBitwiseAnd(Variable node.Node, Expression node.Node) *BitwiseAnd {
return &BitwiseAnd{
Left: Variable,
Right: Expression,
FreeFloating: nil,
Left: Variable,
Right: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *BitwiseAnd) GetPosition() *position.Position {
return n.Position
}
func (n *BitwiseAnd) GetMeta() *meta.Collection {
return &n.Meta
func (n *BitwiseAnd) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package binary
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// BitwiseOr node
type BitwiseOr struct {
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
FreeFloating freefloating.Collection
Position *position.Position
Left node.Node
Right node.Node
}
// NewBitwiseOr node constructor
func NewBitwiseOr(Variable node.Node, Expression node.Node) *BitwiseOr {
return &BitwiseOr{
Left: Variable,
Right: Expression,
FreeFloating: nil,
Left: Variable,
Right: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *BitwiseOr) GetPosition() *position.Position {
return n.Position
}
func (n *BitwiseOr) GetMeta() *meta.Collection {
return &n.Meta
func (n *BitwiseOr) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package binary
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// BitwiseXor node
type BitwiseXor struct {
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
FreeFloating freefloating.Collection
Position *position.Position
Left node.Node
Right node.Node
}
// NewBitwiseXor node constructor
func NewBitwiseXor(Variable node.Node, Expression node.Node) *BitwiseXor {
return &BitwiseXor{
Left: Variable,
Right: Expression,
FreeFloating: nil,
Left: Variable,
Right: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *BitwiseXor) GetPosition() *position.Position {
return n.Position
}
func (n *BitwiseXor) GetMeta() *meta.Collection {
return &n.Meta
func (n *BitwiseXor) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package binary
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// BooleanAnd node
type BooleanAnd struct {
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
FreeFloating freefloating.Collection
Position *position.Position
Left node.Node
Right node.Node
}
// NewBooleanAnd node constructor
func NewBooleanAnd(Variable node.Node, Expression node.Node) *BooleanAnd {
return &BooleanAnd{
Left: Variable,
Right: Expression,
FreeFloating: nil,
Left: Variable,
Right: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *BooleanAnd) GetPosition() *position.Position {
return n.Position
}
func (n *BooleanAnd) GetMeta() *meta.Collection {
return &n.Meta
func (n *BooleanAnd) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package binary
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// BooleanOr node
type BooleanOr struct {
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
FreeFloating freefloating.Collection
Position *position.Position
Left node.Node
Right node.Node
}
// NewBooleanOr node constructor
func NewBooleanOr(Variable node.Node, Expression node.Node) *BooleanOr {
return &BooleanOr{
Left: Variable,
Right: Expression,
FreeFloating: nil,
Left: Variable,
Right: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *BooleanOr) GetPosition() *position.Position {
return n.Position
}
func (n *BooleanOr) GetMeta() *meta.Collection {
return &n.Meta
func (n *BooleanOr) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package binary
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// Coalesce node
type Coalesce struct {
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
FreeFloating freefloating.Collection
Position *position.Position
Left node.Node
Right node.Node
}
// NewCoalesce node constructor
func NewCoalesce(Variable node.Node, Expression node.Node) *Coalesce {
return &Coalesce{
Left: Variable,
Right: Expression,
FreeFloating: nil,
Left: Variable,
Right: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *Coalesce) GetPosition() *position.Position {
return n.Position
}
func (n *Coalesce) GetMeta() *meta.Collection {
return &n.Meta
func (n *Coalesce) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package binary
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// Concat node
type Concat struct {
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
FreeFloating freefloating.Collection
Position *position.Position
Left node.Node
Right node.Node
}
// NewConcat node constructor
func NewConcat(Variable node.Node, Expression node.Node) *Concat {
return &Concat{
Left: Variable,
Right: Expression,
FreeFloating: nil,
Left: Variable,
Right: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *Concat) GetPosition() *position.Position {
return n.Position
}
func (n *Concat) GetMeta() *meta.Collection {
return &n.Meta
func (n *Concat) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package binary
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// Div node
type Div struct {
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
FreeFloating freefloating.Collection
Position *position.Position
Left node.Node
Right node.Node
}
// NewDiv node constructor
func NewDiv(Variable node.Node, Expression node.Node) *Div {
return &Div{
Left: Variable,
Right: Expression,
FreeFloating: nil,
Left: Variable,
Right: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *Div) GetPosition() *position.Position {
return n.Position
}
func (n *Div) GetMeta() *meta.Collection {
return &n.Meta
func (n *Div) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package binary
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// Equal node
type Equal struct {
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
FreeFloating freefloating.Collection
Position *position.Position
Left node.Node
Right node.Node
}
// NewEqual node constructor
func NewEqual(Variable node.Node, Expression node.Node) *Equal {
return &Equal{
Left: Variable,
Right: Expression,
FreeFloating: nil,
Left: Variable,
Right: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *Equal) GetPosition() *position.Position {
return n.Position
}
func (n *Equal) GetMeta() *meta.Collection {
return &n.Meta
func (n *Equal) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package binary
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// Greater node
type Greater struct {
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
FreeFloating freefloating.Collection
Position *position.Position
Left node.Node
Right node.Node
}
// NewGreater node constructor
func NewGreater(Variable node.Node, Expression node.Node) *Greater {
return &Greater{
Left: Variable,
Right: Expression,
FreeFloating: nil,
Left: Variable,
Right: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *Greater) GetPosition() *position.Position {
return n.Position
}
func (n *Greater) GetMeta() *meta.Collection {
return &n.Meta
func (n *Greater) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package binary
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// GreaterOrEqual node
type GreaterOrEqual struct {
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
FreeFloating freefloating.Collection
Position *position.Position
Left node.Node
Right node.Node
}
// NewGreaterOrEqual node constructor
func NewGreaterOrEqual(Variable node.Node, Expression node.Node) *GreaterOrEqual {
return &GreaterOrEqual{
Left: Variable,
Right: Expression,
FreeFloating: nil,
Left: Variable,
Right: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *GreaterOrEqual) GetPosition() *position.Position {
return n.Position
}
func (n *GreaterOrEqual) GetMeta() *meta.Collection {
return &n.Meta
func (n *GreaterOrEqual) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package binary
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// Identical node
type Identical struct {
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
FreeFloating freefloating.Collection
Position *position.Position
Left node.Node
Right node.Node
}
// NewIdentical node constructor
func NewIdentical(Variable node.Node, Expression node.Node) *Identical {
return &Identical{
Left: Variable,
Right: Expression,
FreeFloating: nil,
Left: Variable,
Right: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *Identical) GetPosition() *position.Position {
return n.Position
}
func (n *Identical) GetMeta() *meta.Collection {
return &n.Meta
func (n *Identical) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package binary
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// LogicalAnd node
type LogicalAnd struct {
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
FreeFloating freefloating.Collection
Position *position.Position
Left node.Node
Right node.Node
}
// NewLogicalAnd node constructor
func NewLogicalAnd(Variable node.Node, Expression node.Node) *LogicalAnd {
return &LogicalAnd{
Left: Variable,
Right: Expression,
FreeFloating: nil,
Left: Variable,
Right: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *LogicalAnd) GetPosition() *position.Position {
return n.Position
}
func (n *LogicalAnd) GetMeta() *meta.Collection {
return &n.Meta
func (n *LogicalAnd) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package binary
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// LogicalOr node
type LogicalOr struct {
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
FreeFloating freefloating.Collection
Position *position.Position
Left node.Node
Right node.Node
}
// NewLogicalOr node constructor
func NewLogicalOr(Variable node.Node, Expression node.Node) *LogicalOr {
return &LogicalOr{
Left: Variable,
Right: Expression,
FreeFloating: nil,
Left: Variable,
Right: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *LogicalOr) GetPosition() *position.Position {
return n.Position
}
func (n *LogicalOr) GetMeta() *meta.Collection {
return &n.Meta
func (n *LogicalOr) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package binary
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// LogicalXor node
type LogicalXor struct {
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
FreeFloating freefloating.Collection
Position *position.Position
Left node.Node
Right node.Node
}
// NewLogicalXor node constructor
func NewLogicalXor(Variable node.Node, Expression node.Node) *LogicalXor {
return &LogicalXor{
Left: Variable,
Right: Expression,
FreeFloating: nil,
Left: Variable,
Right: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *LogicalXor) GetPosition() *position.Position {
return n.Position
}
func (n *LogicalXor) GetMeta() *meta.Collection {
return &n.Meta
func (n *LogicalXor) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package binary
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// Minus node
type Minus struct {
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
FreeFloating freefloating.Collection
Position *position.Position
Left node.Node
Right node.Node
}
// NewMinus node constructor
func NewMinus(Variable node.Node, Expression node.Node) *Minus {
return &Minus{
Left: Variable,
Right: Expression,
FreeFloating: nil,
Left: Variable,
Right: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *Minus) GetPosition() *position.Position {
return n.Position
}
func (n *Minus) GetMeta() *meta.Collection {
return &n.Meta
func (n *Minus) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package binary
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// Mod node
type Mod struct {
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
FreeFloating freefloating.Collection
Position *position.Position
Left node.Node
Right node.Node
}
// NewMod node constructor
func NewMod(Variable node.Node, Expression node.Node) *Mod {
return &Mod{
Left: Variable,
Right: Expression,
FreeFloating: nil,
Left: Variable,
Right: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *Mod) GetPosition() *position.Position {
return n.Position
}
func (n *Mod) GetMeta() *meta.Collection {
return &n.Meta
func (n *Mod) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package binary
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// Mul node
type Mul struct {
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
FreeFloating freefloating.Collection
Position *position.Position
Left node.Node
Right node.Node
}
// NewMul node constructor
func NewMul(Variable node.Node, Expression node.Node) *Mul {
return &Mul{
Left: Variable,
Right: Expression,
FreeFloating: nil,
Left: Variable,
Right: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *Mul) GetPosition() *position.Position {
return n.Position
}
func (n *Mul) GetMeta() *meta.Collection {
return &n.Meta
func (n *Mul) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package binary
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// NotEqual node
type NotEqual struct {
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
FreeFloating freefloating.Collection
Position *position.Position
Left node.Node
Right node.Node
}
// NewNotEqual node constructor
func NewNotEqual(Variable node.Node, Expression node.Node) *NotEqual {
return &NotEqual{
Left: Variable,
Right: Expression,
FreeFloating: nil,
Left: Variable,
Right: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *NotEqual) GetPosition() *position.Position {
return n.Position
}
func (n *NotEqual) GetMeta() *meta.Collection {
return &n.Meta
func (n *NotEqual) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package binary
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// NotIdentical node
type NotIdentical struct {
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
FreeFloating freefloating.Collection
Position *position.Position
Left node.Node
Right node.Node
}
// NewNotIdentical node constructor
func NewNotIdentical(Variable node.Node, Expression node.Node) *NotIdentical {
return &NotIdentical{
Left: Variable,
Right: Expression,
FreeFloating: nil,
Left: Variable,
Right: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *NotIdentical) GetPosition() *position.Position {
return n.Position
}
func (n *NotIdentical) GetMeta() *meta.Collection {
return &n.Meta
func (n *NotIdentical) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package binary
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// Plus node
type Plus struct {
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
FreeFloating freefloating.Collection
Position *position.Position
Left node.Node
Right node.Node
}
// NewPlus node constructor
func NewPlus(Variable node.Node, Expression node.Node) *Plus {
return &Plus{
Left: Variable,
Right: Expression,
FreeFloating: nil,
Left: Variable,
Right: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *Plus) GetPosition() *position.Position {
return n.Position
}
func (n *Plus) GetMeta() *meta.Collection {
return &n.Meta
func (n *Plus) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package binary
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// Pow node
type Pow struct {
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
FreeFloating freefloating.Collection
Position *position.Position
Left node.Node
Right node.Node
}
// NewPow node constructor
func NewPow(Variable node.Node, Expression node.Node) *Pow {
return &Pow{
Left: Variable,
Right: Expression,
FreeFloating: nil,
Left: Variable,
Right: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *Pow) GetPosition() *position.Position {
return n.Position
}
func (n *Pow) GetMeta() *meta.Collection {
return &n.Meta
func (n *Pow) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package binary
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// ShiftLeft node
type ShiftLeft struct {
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
FreeFloating freefloating.Collection
Position *position.Position
Left node.Node
Right node.Node
}
// NewShiftLeft node constructor
func NewShiftLeft(Variable node.Node, Expression node.Node) *ShiftLeft {
return &ShiftLeft{
Left: Variable,
Right: Expression,
FreeFloating: nil,
Left: Variable,
Right: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *ShiftLeft) GetPosition() *position.Position {
return n.Position
}
func (n *ShiftLeft) GetMeta() *meta.Collection {
return &n.Meta
func (n *ShiftLeft) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package binary
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// ShiftRight node
type ShiftRight struct {
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
FreeFloating freefloating.Collection
Position *position.Position
Left node.Node
Right node.Node
}
// NewShiftRight node constructor
func NewShiftRight(Variable node.Node, Expression node.Node) *ShiftRight {
return &ShiftRight{
Left: Variable,
Right: Expression,
FreeFloating: nil,
Left: Variable,
Right: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *ShiftRight) GetPosition() *position.Position {
return n.Position
}
func (n *ShiftRight) GetMeta() *meta.Collection {
return &n.Meta
func (n *ShiftRight) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package binary
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// Smaller node
type Smaller struct {
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
FreeFloating freefloating.Collection
Position *position.Position
Left node.Node
Right node.Node
}
// NewSmaller node constructor
func NewSmaller(Variable node.Node, Expression node.Node) *Smaller {
return &Smaller{
Left: Variable,
Right: Expression,
FreeFloating: nil,
Left: Variable,
Right: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *Smaller) GetPosition() *position.Position {
return n.Position
}
func (n *Smaller) GetMeta() *meta.Collection {
return &n.Meta
func (n *Smaller) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package binary
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// SmallerOrEqual node
type SmallerOrEqual struct {
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
FreeFloating freefloating.Collection
Position *position.Position
Left node.Node
Right node.Node
}
// NewSmallerOrEqual node constructor
func NewSmallerOrEqual(Variable node.Node, Expression node.Node) *SmallerOrEqual {
return &SmallerOrEqual{
Left: Variable,
Right: Expression,
FreeFloating: nil,
Left: Variable,
Right: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *SmallerOrEqual) GetPosition() *position.Position {
return n.Position
}
func (n *SmallerOrEqual) GetMeta() *meta.Collection {
return &n.Meta
func (n *SmallerOrEqual) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -1,7 +1,7 @@
package binary
import (
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/position"
"github.com/z7zmey/php-parser/walker"
@@ -9,17 +9,18 @@ import (
// Spaceship node
type Spaceship struct {
Meta meta.Collection
Position *position.Position
Left node.Node
Right node.Node
FreeFloating freefloating.Collection
Position *position.Position
Left node.Node
Right node.Node
}
// NewSpaceship node constructor
func NewSpaceship(Variable node.Node, Expression node.Node) *Spaceship {
return &Spaceship{
Left: Variable,
Right: Expression,
FreeFloating: nil,
Left: Variable,
Right: Expression,
}
}
@@ -33,8 +34,8 @@ func (n *Spaceship) GetPosition() *position.Position {
return n.Position
}
func (n *Spaceship) GetMeta() *meta.Collection {
return &n.Meta
func (n *Spaceship) GetFreeFloating() *freefloating.Collection {
return &n.FreeFloating
}
// Attributes returns node attributes as map

View File

@@ -2,10 +2,9 @@ package binary_test
import (
"bytes"
"reflect"
"testing"
"github.com/kylelemons/godebug/pretty"
"gotest.tools/assert"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/node/expr"
@@ -16,18 +15,6 @@ import (
"github.com/z7zmey/php-parser/position"
)
func assertEqual(t *testing.T, expected interface{}, actual interface{}) {
if !reflect.DeepEqual(expected, actual) {
diff := pretty.Compare(expected, actual)
if diff != "" {
t.Errorf("diff: (-expected +actual)\n%s", diff)
} else {
t.Errorf("expected and actual are not equal\n")
}
}
}
func TestBitwiseAnd(t *testing.T) {
src := `<? $a & $b;`
@@ -95,12 +82,12 @@ func TestBitwiseAnd(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestBitwiseOr(t *testing.T) {
@@ -170,12 +157,12 @@ func TestBitwiseOr(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestBitwiseXor(t *testing.T) {
@@ -245,12 +232,12 @@ func TestBitwiseXor(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestBooleanAnd(t *testing.T) {
@@ -320,12 +307,12 @@ func TestBooleanAnd(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestBooleanOr(t *testing.T) {
@@ -395,12 +382,12 @@ func TestBooleanOr(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestCoalesce(t *testing.T) {
@@ -470,7 +457,7 @@ func TestCoalesce(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestConcat(t *testing.T) {
@@ -540,12 +527,12 @@ func TestConcat(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestDiv(t *testing.T) {
@@ -615,12 +602,12 @@ func TestDiv(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestEqual(t *testing.T) {
@@ -690,12 +677,12 @@ func TestEqual(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestGreaterOrEqual(t *testing.T) {
@@ -765,12 +752,12 @@ func TestGreaterOrEqual(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestGreater(t *testing.T) {
@@ -840,12 +827,12 @@ func TestGreater(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestIdentical(t *testing.T) {
@@ -915,12 +902,12 @@ func TestIdentical(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestLogicalAnd(t *testing.T) {
@@ -990,12 +977,12 @@ func TestLogicalAnd(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestLogicalOr(t *testing.T) {
@@ -1065,12 +1052,12 @@ func TestLogicalOr(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestLogicalXor(t *testing.T) {
@@ -1140,12 +1127,12 @@ func TestLogicalXor(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestMinus(t *testing.T) {
@@ -1215,12 +1202,12 @@ func TestMinus(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestMod(t *testing.T) {
@@ -1290,12 +1277,12 @@ func TestMod(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestMul(t *testing.T) {
@@ -1365,12 +1352,12 @@ func TestMul(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestNotEqual(t *testing.T) {
@@ -1440,12 +1427,12 @@ func TestNotEqual(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestNotIdentical(t *testing.T) {
@@ -1515,12 +1502,12 @@ func TestNotIdentical(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestPlus(t *testing.T) {
@@ -1590,12 +1577,12 @@ func TestPlus(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestPow(t *testing.T) {
@@ -1665,12 +1652,12 @@ func TestPow(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestShiftLeft(t *testing.T) {
@@ -1740,12 +1727,12 @@ func TestShiftLeft(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestShiftRight(t *testing.T) {
@@ -1815,12 +1802,12 @@ func TestShiftRight(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestSmallerOrEqual(t *testing.T) {
@@ -1890,12 +1877,12 @@ func TestSmallerOrEqual(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestSmaller(t *testing.T) {
@@ -1965,12 +1952,12 @@ func TestSmaller(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
func TestSpaceship(t *testing.T) {
@@ -2040,5 +2027,5 @@ func TestSpaceship(t *testing.T) {
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}

View File

@@ -0,0 +1,117 @@
package binary_test
import (
"testing"
"gotest.tools/assert"
"github.com/z7zmey/php-parser/freefloating"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/node/expr/binary"
)
var expected freefloating.Collection = freefloating.Collection{
freefloating.Start: []freefloating.String{
{
StringType: freefloating.WhiteSpaceType,
Value: " ",
Position: nil,
},
{
StringType: freefloating.CommentType,
Value: "//comment\n",
Position: nil,
},
},
}
var nodes = []node.Node{
&binary.BitwiseAnd{
FreeFloating: expected,
},
&binary.BitwiseOr{
FreeFloating: expected,
},
&binary.BitwiseXor{
FreeFloating: expected,
},
&binary.BooleanAnd{
FreeFloating: expected,
},
&binary.BooleanOr{
FreeFloating: expected,
},
&binary.Coalesce{
FreeFloating: expected,
},
&binary.Concat{
FreeFloating: expected,
},
&binary.Div{
FreeFloating: expected,
},
&binary.Equal{
FreeFloating: expected,
},
&binary.GreaterOrEqual{
FreeFloating: expected,
},
&binary.Greater{
FreeFloating: expected,
},
&binary.Identical{
FreeFloating: expected,
},
&binary.LogicalAnd{
FreeFloating: expected,
},
&binary.LogicalOr{
FreeFloating: expected,
},
&binary.LogicalXor{
FreeFloating: expected,
},
&binary.Minus{
FreeFloating: expected,
},
&binary.Mod{
FreeFloating: expected,
},
&binary.Mul{
FreeFloating: expected,
},
&binary.NotEqual{
FreeFloating: expected,
},
&binary.NotIdentical{
FreeFloating: expected,
},
&binary.Plus{
FreeFloating: expected,
},
&binary.Pow{
FreeFloating: expected,
},
&binary.ShiftLeft{
FreeFloating: expected,
},
&binary.ShiftRight{
FreeFloating: expected,
},
&binary.SmallerOrEqual{
FreeFloating: expected,
},
&binary.Smaller{
FreeFloating: expected,
},
&binary.Spaceship{
FreeFloating: expected,
},
}
func TestMeta(t *testing.T) {
for _, n := range nodes {
actual := *n.GetFreeFloating()
assert.DeepEqual(t, expected, actual)
}
}

View File

@@ -1,61 +0,0 @@
package binary_test
import (
"testing"
"github.com/z7zmey/php-parser/node/expr/binary"
"github.com/z7zmey/php-parser/meta"
"github.com/z7zmey/php-parser/node"
)
var nodes = []node.Node{
&binary.BitwiseAnd{},
&binary.BitwiseOr{},
&binary.BitwiseXor{},
&binary.BooleanAnd{},
&binary.BooleanOr{},
&binary.Coalesce{},
&binary.Concat{},
&binary.Div{},
&binary.Equal{},
&binary.GreaterOrEqual{},
&binary.Greater{},
&binary.Identical{},
&binary.LogicalAnd{},
&binary.LogicalOr{},
&binary.LogicalXor{},
&binary.Minus{},
&binary.Mod{},
&binary.Mul{},
&binary.NotEqual{},
&binary.NotIdentical{},
&binary.Plus{},
&binary.Pow{},
&binary.ShiftLeft{},
&binary.ShiftRight{},
&binary.SmallerOrEqual{},
&binary.Smaller{},
&binary.Spaceship{},
}
func TestMeta(t *testing.T) {
expected := &meta.Collection{
&meta.Data{
Value: "//comment\n",
Type: meta.CommentType,
Position: nil,
},
&meta.Data{
Value: " ",
Type: meta.WhiteSpaceType,
Position: nil,
},
}
for _, n := range nodes {
n.GetMeta().Push(*expected...)
actual := n.GetMeta()
assertEqual(t, expected, actual)
}
}

View File

@@ -3,6 +3,8 @@ package binary_test
import (
"testing"
"gotest.tools/assert"
"github.com/z7zmey/php-parser/position"
)
@@ -11,6 +13,6 @@ func TestPosition(t *testing.T) {
for _, n := range nodes {
n.SetPosition(expected)
actual := n.GetPosition()
assertEqual(t, expected, actual)
assert.DeepEqual(t, expected, actual)
}
}

View File

@@ -1,15 +1,13 @@
package binary_test
import (
"reflect"
"testing"
"github.com/kylelemons/godebug/pretty"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/node/expr"
"github.com/z7zmey/php-parser/node/expr/binary"
"github.com/z7zmey/php-parser/walker"
"gotest.tools/assert"
)
var nodesToTest = []struct {
@@ -23,7 +21,7 @@ var nodesToTest = []struct {
Right: &expr.Variable{},
},
[]string{"Left", "Right"},
map[string]interface{}{},
nil,
},
{
&binary.BitwiseOr{
@@ -31,7 +29,7 @@ var nodesToTest = []struct {
Right: &expr.Variable{},
},
[]string{"Left", "Right"},
map[string]interface{}{},
nil,
},
{
&binary.BitwiseXor{
@@ -39,7 +37,7 @@ var nodesToTest = []struct {
Right: &expr.Variable{},
},
[]string{"Left", "Right"},
map[string]interface{}{},
nil,
},
{
&binary.BooleanAnd{
@@ -47,7 +45,7 @@ var nodesToTest = []struct {
Right: &expr.Variable{},
},
[]string{"Left", "Right"},
map[string]interface{}{},
nil,
},
{
&binary.BooleanOr{
@@ -55,7 +53,7 @@ var nodesToTest = []struct {
Right: &expr.Variable{},
},
[]string{"Left", "Right"},
map[string]interface{}{},
nil,
},
{
&binary.Coalesce{
@@ -63,7 +61,7 @@ var nodesToTest = []struct {
Right: &expr.Variable{},
},
[]string{"Left", "Right"},
map[string]interface{}{},
nil,
},
{
&binary.Concat{
@@ -71,7 +69,7 @@ var nodesToTest = []struct {
Right: &expr.Variable{},
},
[]string{"Left", "Right"},
map[string]interface{}{},
nil,
},
{
&binary.Div{
@@ -79,7 +77,7 @@ var nodesToTest = []struct {
Right: &expr.Variable{},
},
[]string{"Left", "Right"},
map[string]interface{}{},
nil,
},
{
&binary.Equal{
@@ -87,7 +85,7 @@ var nodesToTest = []struct {
Right: &expr.Variable{},
},
[]string{"Left", "Right"},
map[string]interface{}{},
nil,
},
{
&binary.GreaterOrEqual{
@@ -95,7 +93,7 @@ var nodesToTest = []struct {
Right: &expr.Variable{},
},
[]string{"Left", "Right"},
map[string]interface{}{},
nil,
},
{
&binary.Greater{
@@ -103,7 +101,7 @@ var nodesToTest = []struct {
Right: &expr.Variable{},
},
[]string{"Left", "Right"},
map[string]interface{}{},
nil,
},
{
&binary.Identical{
@@ -111,7 +109,7 @@ var nodesToTest = []struct {
Right: &expr.Variable{},
},
[]string{"Left", "Right"},
map[string]interface{}{},
nil,
},
{
&binary.LogicalAnd{
@@ -119,7 +117,7 @@ var nodesToTest = []struct {
Right: &expr.Variable{},
},
[]string{"Left", "Right"},
map[string]interface{}{},
nil,
},
{
&binary.LogicalOr{
@@ -127,7 +125,7 @@ var nodesToTest = []struct {
Right: &expr.Variable{},
},
[]string{"Left", "Right"},
map[string]interface{}{},
nil,
},
{
&binary.LogicalXor{
@@ -135,7 +133,7 @@ var nodesToTest = []struct {
Right: &expr.Variable{},
},
[]string{"Left", "Right"},
map[string]interface{}{},
nil,
},
{
&binary.Minus{
@@ -143,7 +141,7 @@ var nodesToTest = []struct {
Right: &expr.Variable{},
},
[]string{"Left", "Right"},
map[string]interface{}{},
nil,
},
{
&binary.Mod{
@@ -151,7 +149,7 @@ var nodesToTest = []struct {
Right: &expr.Variable{},
},
[]string{"Left", "Right"},
map[string]interface{}{},
nil,
},
{
&binary.Mul{
@@ -159,7 +157,7 @@ var nodesToTest = []struct {
Right: &expr.Variable{},
},
[]string{"Left", "Right"},
map[string]interface{}{},
nil,
},
{
&binary.NotEqual{
@@ -167,7 +165,7 @@ var nodesToTest = []struct {
Right: &expr.Variable{},
},
[]string{"Left", "Right"},
map[string]interface{}{},
nil,
},
{
&binary.NotIdentical{
@@ -175,7 +173,7 @@ var nodesToTest = []struct {
Right: &expr.Variable{},
},
[]string{"Left", "Right"},
map[string]interface{}{},
nil,
},
{
&binary.Plus{
@@ -183,7 +181,7 @@ var nodesToTest = []struct {
Right: &expr.Variable{},
},
[]string{"Left", "Right"},
map[string]interface{}{},
nil,
},
{
&binary.Pow{
@@ -191,7 +189,7 @@ var nodesToTest = []struct {
Right: &expr.Variable{},
},
[]string{"Left", "Right"},
map[string]interface{}{},
nil,
},
{
&binary.ShiftLeft{
@@ -199,7 +197,7 @@ var nodesToTest = []struct {
Right: &expr.Variable{},
},
[]string{"Left", "Right"},
map[string]interface{}{},
nil,
},
{
&binary.ShiftRight{
@@ -207,7 +205,7 @@ var nodesToTest = []struct {
Right: &expr.Variable{},
},
[]string{"Left", "Right"},
map[string]interface{}{},
nil,
},
{
&binary.SmallerOrEqual{
@@ -215,7 +213,7 @@ var nodesToTest = []struct {
Right: &expr.Variable{},
},
[]string{"Left", "Right"},
map[string]interface{}{},
nil,
},
{
&binary.Smaller{
@@ -223,7 +221,7 @@ var nodesToTest = []struct {
Right: &expr.Variable{},
},
[]string{"Left", "Right"},
map[string]interface{}{},
nil,
},
{
&binary.Spaceship{
@@ -231,7 +229,7 @@ var nodesToTest = []struct {
Right: &expr.Variable{},
},
[]string{"Left", "Right"},
map[string]interface{}{},
nil,
},
}
@@ -253,31 +251,25 @@ func (v *visitorMock) LeaveChildList(key string, w walker.Walkable) {}
func TestVisitorDisableChildren(t *testing.T) {
for _, tt := range nodesToTest {
v := &visitorMock{false, nil}
v := &visitorMock{false, []string{}}
tt.node.Walk(v)
expected := []string{}
actual := v.visitedKeys
diff := pretty.Compare(expected, actual)
if diff != "" {
t.Errorf("%s diff: (-expected +actual)\n%s", reflect.TypeOf(tt.node), diff)
}
assert.DeepEqual(t, expected, actual)
}
}
func TestVisitor(t *testing.T) {
for _, tt := range nodesToTest {
v := &visitorMock{true, nil}
v := &visitorMock{true, []string{}}
tt.node.Walk(v)
expected := tt.expectedVisitedKeys
actual := v.visitedKeys
diff := pretty.Compare(expected, actual)
if diff != "" {
t.Errorf("%s diff: (-expected +actual)\n%s", reflect.TypeOf(tt.node), diff)
}
assert.DeepEqual(t, expected, actual)
}
}
@@ -288,9 +280,6 @@ func TestNameAttributes(t *testing.T) {
expected := tt.expectedAttributes
actual := tt.node.Attributes()
diff := pretty.Compare(expected, actual)
if diff != "" {
t.Errorf("%s diff: (-expected +actual)\n%s", reflect.TypeOf(tt.node), diff)
}
assert.DeepEqual(t, expected, actual)
}
}