diff --git a/node/expr/binary_op/n_binary_op.go b/node/expr/binary_op/n_binary_op.go deleted file mode 100644 index 1d6b925..0000000 --- a/node/expr/binary_op/n_binary_op.go +++ /dev/null @@ -1,11 +0,0 @@ -package binary_op - -import ( - "github.com/z7zmey/php-parser/node" -) - -// BinaryOp node -type BinaryOp struct { - Left node.Node - Right node.Node -} diff --git a/node/expr/binary_op/n_bitwise_and.go b/node/expr/binary_op/n_bitwise_and.go index ce77975..6bcdb39 100644 --- a/node/expr/binary_op/n_bitwise_and.go +++ b/node/expr/binary_op/n_bitwise_and.go @@ -7,16 +7,15 @@ import ( // BitwiseAnd node type BitwiseAnd struct { - BinaryOp + Left node.Node + Right node.Node } // NewBitwiseAnd node constuctor func NewBitwiseAnd(Variable node.Node, Expression node.Node) *BitwiseAnd { return &BitwiseAnd{ - BinaryOp{ - Variable, - Expression, - }, + Variable, + Expression, } } diff --git a/node/expr/binary_op/n_bitwise_or.go b/node/expr/binary_op/n_bitwise_or.go index 017769c..7fa9082 100644 --- a/node/expr/binary_op/n_bitwise_or.go +++ b/node/expr/binary_op/n_bitwise_or.go @@ -7,16 +7,15 @@ import ( // BitwiseOr node type BitwiseOr struct { - BinaryOp + Left node.Node + Right node.Node } // NewBitwiseOr node constuctor func NewBitwiseOr(Variable node.Node, Expression node.Node) *BitwiseOr { return &BitwiseOr{ - BinaryOp{ - Variable, - Expression, - }, + Variable, + Expression, } } diff --git a/node/expr/binary_op/n_bitwise_xor.go b/node/expr/binary_op/n_bitwise_xor.go index 24d97f7..39e5dd5 100644 --- a/node/expr/binary_op/n_bitwise_xor.go +++ b/node/expr/binary_op/n_bitwise_xor.go @@ -7,16 +7,15 @@ import ( // BitwiseXor node type BitwiseXor struct { - BinaryOp + Left node.Node + Right node.Node } // NewBitwiseXor node constuctor func NewBitwiseXor(Variable node.Node, Expression node.Node) *BitwiseXor { return &BitwiseXor{ - BinaryOp{ - Variable, - Expression, - }, + Variable, + Expression, } } diff --git a/node/expr/binary_op/n_boolean_and.go b/node/expr/binary_op/n_boolean_and.go index e6319c0..6d43985 100644 --- a/node/expr/binary_op/n_boolean_and.go +++ b/node/expr/binary_op/n_boolean_and.go @@ -7,16 +7,15 @@ import ( // BooleanAnd node type BooleanAnd struct { - BinaryOp + Left node.Node + Right node.Node } // NewBooleanAnd node constuctor func NewBooleanAnd(Variable node.Node, Expression node.Node) *BooleanAnd { return &BooleanAnd{ - BinaryOp{ - Variable, - Expression, - }, + Variable, + Expression, } } diff --git a/node/expr/binary_op/n_boolean_or.go b/node/expr/binary_op/n_boolean_or.go index e9b7e42..8ea3321 100644 --- a/node/expr/binary_op/n_boolean_or.go +++ b/node/expr/binary_op/n_boolean_or.go @@ -7,16 +7,15 @@ import ( // BooleanOr node type BooleanOr struct { - BinaryOp + Left node.Node + Right node.Node } // NewBooleanOr node constuctor func NewBooleanOr(Variable node.Node, Expression node.Node) *BooleanOr { return &BooleanOr{ - BinaryOp{ - Variable, - Expression, - }, + Variable, + Expression, } } diff --git a/node/expr/binary_op/n_coalesce.go b/node/expr/binary_op/n_coalesce.go index 0efd847..c82d1f8 100644 --- a/node/expr/binary_op/n_coalesce.go +++ b/node/expr/binary_op/n_coalesce.go @@ -7,16 +7,15 @@ import ( // Coalesce node type Coalesce struct { - BinaryOp + Left node.Node + Right node.Node } // NewCoalesce node constuctor func NewCoalesce(Variable node.Node, Expression node.Node) *Coalesce { return &Coalesce{ - BinaryOp{ - Variable, - Expression, - }, + Variable, + Expression, } } diff --git a/node/expr/binary_op/n_concat.go b/node/expr/binary_op/n_concat.go index 19c1b85..747cce5 100644 --- a/node/expr/binary_op/n_concat.go +++ b/node/expr/binary_op/n_concat.go @@ -7,16 +7,15 @@ import ( // Concat node type Concat struct { - BinaryOp + Left node.Node + Right node.Node } // NewConcat node constuctor func NewConcat(Variable node.Node, Expression node.Node) *Concat { return &Concat{ - BinaryOp{ - Variable, - Expression, - }, + Variable, + Expression, } } diff --git a/node/expr/binary_op/n_div.go b/node/expr/binary_op/n_div.go index c2c5f17..1ea65fb 100644 --- a/node/expr/binary_op/n_div.go +++ b/node/expr/binary_op/n_div.go @@ -7,16 +7,15 @@ import ( // Div node type Div struct { - BinaryOp + Left node.Node + Right node.Node } // NewDiv node constuctor func NewDiv(Variable node.Node, Expression node.Node) *Div { return &Div{ - BinaryOp{ - Variable, - Expression, - }, + Variable, + Expression, } } diff --git a/node/expr/binary_op/n_equal.go b/node/expr/binary_op/n_equal.go index a17d019..50d107e 100644 --- a/node/expr/binary_op/n_equal.go +++ b/node/expr/binary_op/n_equal.go @@ -7,16 +7,15 @@ import ( // Equal node type Equal struct { - BinaryOp + Left node.Node + Right node.Node } // NewEqual node constuctor func NewEqual(Variable node.Node, Expression node.Node) *Equal { return &Equal{ - BinaryOp{ - Variable, - Expression, - }, + Variable, + Expression, } } diff --git a/node/expr/binary_op/n_greater.go b/node/expr/binary_op/n_greater.go index 58e161d..e408b8b 100644 --- a/node/expr/binary_op/n_greater.go +++ b/node/expr/binary_op/n_greater.go @@ -7,16 +7,15 @@ import ( // Greater node type Greater struct { - BinaryOp + Left node.Node + Right node.Node } // NewGreater node constuctor func NewGreater(Variable node.Node, Expression node.Node) *Greater { return &Greater{ - BinaryOp{ - Variable, - Expression, - }, + Variable, + Expression, } } diff --git a/node/expr/binary_op/n_greater_or_equal.go b/node/expr/binary_op/n_greater_or_equal.go index d3e5e6f..655e365 100644 --- a/node/expr/binary_op/n_greater_or_equal.go +++ b/node/expr/binary_op/n_greater_or_equal.go @@ -7,16 +7,15 @@ import ( // GreaterOrEqual node type GreaterOrEqual struct { - BinaryOp + Left node.Node + Right node.Node } // NewGreaterOrEqual node constuctor func NewGreaterOrEqual(Variable node.Node, Expression node.Node) *GreaterOrEqual { return &GreaterOrEqual{ - BinaryOp{ - Variable, - Expression, - }, + Variable, + Expression, } } diff --git a/node/expr/binary_op/n_identical.go b/node/expr/binary_op/n_identical.go index 273af66..6eadc70 100644 --- a/node/expr/binary_op/n_identical.go +++ b/node/expr/binary_op/n_identical.go @@ -7,16 +7,15 @@ import ( // Identical node type Identical struct { - BinaryOp + Left node.Node + Right node.Node } // NewIdentical node constuctor func NewIdentical(Variable node.Node, Expression node.Node) *Identical { return &Identical{ - BinaryOp{ - Variable, - Expression, - }, + Variable, + Expression, } } diff --git a/node/expr/binary_op/n_logical_and.go b/node/expr/binary_op/n_logical_and.go index 2469424..343c3e8 100644 --- a/node/expr/binary_op/n_logical_and.go +++ b/node/expr/binary_op/n_logical_and.go @@ -7,16 +7,15 @@ import ( // LogicalAnd node type LogicalAnd struct { - BinaryOp + Left node.Node + Right node.Node } // NewLogicalAnd node constuctor func NewLogicalAnd(Variable node.Node, Expression node.Node) *LogicalAnd { return &LogicalAnd{ - BinaryOp{ - Variable, - Expression, - }, + Variable, + Expression, } } diff --git a/node/expr/binary_op/n_logical_or.go b/node/expr/binary_op/n_logical_or.go index 894f926..7f06f2b 100644 --- a/node/expr/binary_op/n_logical_or.go +++ b/node/expr/binary_op/n_logical_or.go @@ -7,16 +7,15 @@ import ( // LogicalOr node type LogicalOr struct { - BinaryOp + Left node.Node + Right node.Node } // NewLogicalOr node constuctor func NewLogicalOr(Variable node.Node, Expression node.Node) *LogicalOr { return &LogicalOr{ - BinaryOp{ - Variable, - Expression, - }, + Variable, + Expression, } } diff --git a/node/expr/binary_op/n_logical_xor.go b/node/expr/binary_op/n_logical_xor.go index 97b3e41..722f6a4 100644 --- a/node/expr/binary_op/n_logical_xor.go +++ b/node/expr/binary_op/n_logical_xor.go @@ -7,16 +7,15 @@ import ( // LogicalXor node type LogicalXor struct { - BinaryOp + Left node.Node + Right node.Node } // NewLogicalXor node constuctor func NewLogicalXor(Variable node.Node, Expression node.Node) *LogicalXor { return &LogicalXor{ - BinaryOp{ - Variable, - Expression, - }, + Variable, + Expression, } } diff --git a/node/expr/binary_op/n_minus.go b/node/expr/binary_op/n_minus.go index ee8057b..e40ea51 100644 --- a/node/expr/binary_op/n_minus.go +++ b/node/expr/binary_op/n_minus.go @@ -7,16 +7,15 @@ import ( // Minus node type Minus struct { - BinaryOp + Left node.Node + Right node.Node } // NewMinus node constuctor func NewMinus(Variable node.Node, Expression node.Node) *Minus { return &Minus{ - BinaryOp{ - Variable, - Expression, - }, + Variable, + Expression, } } diff --git a/node/expr/binary_op/n_mod.go b/node/expr/binary_op/n_mod.go index 81975fe..1b1ba3e 100644 --- a/node/expr/binary_op/n_mod.go +++ b/node/expr/binary_op/n_mod.go @@ -7,16 +7,15 @@ import ( // Mod node type Mod struct { - BinaryOp + Left node.Node + Right node.Node } // NewMod node constuctor func NewMod(Variable node.Node, Expression node.Node) *Mod { return &Mod{ - BinaryOp{ - Variable, - Expression, - }, + Variable, + Expression, } } diff --git a/node/expr/binary_op/n_mul.go b/node/expr/binary_op/n_mul.go index 757d932..f9408c6 100644 --- a/node/expr/binary_op/n_mul.go +++ b/node/expr/binary_op/n_mul.go @@ -7,16 +7,15 @@ import ( // Mul node type Mul struct { - BinaryOp + Left node.Node + Right node.Node } // NewMul node constuctor func NewMul(Variable node.Node, Expression node.Node) *Mul { return &Mul{ - BinaryOp{ - Variable, - Expression, - }, + Variable, + Expression, } } diff --git a/node/expr/binary_op/n_not_equal.go b/node/expr/binary_op/n_not_equal.go index 224812b..3c7e461 100644 --- a/node/expr/binary_op/n_not_equal.go +++ b/node/expr/binary_op/n_not_equal.go @@ -7,16 +7,15 @@ import ( // NotEqual node type NotEqual struct { - BinaryOp + Left node.Node + Right node.Node } // NewNotEqual node constuctor func NewNotEqual(Variable node.Node, Expression node.Node) *NotEqual { return &NotEqual{ - BinaryOp{ - Variable, - Expression, - }, + Variable, + Expression, } } diff --git a/node/expr/binary_op/n_not_identical.go b/node/expr/binary_op/n_not_identical.go index e24e474..a83fe05 100644 --- a/node/expr/binary_op/n_not_identical.go +++ b/node/expr/binary_op/n_not_identical.go @@ -7,16 +7,15 @@ import ( // NotIdentical node type NotIdentical struct { - BinaryOp + Left node.Node + Right node.Node } // NewNotIdentical node constuctor func NewNotIdentical(Variable node.Node, Expression node.Node) *NotIdentical { return &NotIdentical{ - BinaryOp{ - Variable, - Expression, - }, + Variable, + Expression, } } diff --git a/node/expr/binary_op/n_plus.go b/node/expr/binary_op/n_plus.go index f8c8649..6517e75 100644 --- a/node/expr/binary_op/n_plus.go +++ b/node/expr/binary_op/n_plus.go @@ -7,16 +7,15 @@ import ( // Plus node type Plus struct { - BinaryOp + Left node.Node + Right node.Node } // NewPlus node constuctor func NewPlus(Variable node.Node, Expression node.Node) *Plus { return &Plus{ - BinaryOp{ - Variable, - Expression, - }, + Variable, + Expression, } } diff --git a/node/expr/binary_op/n_pow.go b/node/expr/binary_op/n_pow.go index 170c740..2eaee3a 100644 --- a/node/expr/binary_op/n_pow.go +++ b/node/expr/binary_op/n_pow.go @@ -7,16 +7,15 @@ import ( // Pow node type Pow struct { - BinaryOp + Left node.Node + Right node.Node } // NewPow node constuctor func NewPow(Variable node.Node, Expression node.Node) *Pow { return &Pow{ - BinaryOp{ - Variable, - Expression, - }, + Variable, + Expression, } } diff --git a/node/expr/binary_op/n_shift_left.go b/node/expr/binary_op/n_shift_left.go index c1477ef..59358d2 100644 --- a/node/expr/binary_op/n_shift_left.go +++ b/node/expr/binary_op/n_shift_left.go @@ -7,16 +7,15 @@ import ( // ShiftLeft node type ShiftLeft struct { - BinaryOp + Left node.Node + Right node.Node } // NewShiftLeft node constuctor func NewShiftLeft(Variable node.Node, Expression node.Node) *ShiftLeft { return &ShiftLeft{ - BinaryOp{ - Variable, - Expression, - }, + Variable, + Expression, } } diff --git a/node/expr/binary_op/n_shift_right.go b/node/expr/binary_op/n_shift_right.go index e8c9751..594af4d 100644 --- a/node/expr/binary_op/n_shift_right.go +++ b/node/expr/binary_op/n_shift_right.go @@ -7,16 +7,15 @@ import ( // ShiftRight node type ShiftRight struct { - BinaryOp + Left node.Node + Right node.Node } // NewShiftRight node constuctor func NewShiftRight(Variable node.Node, Expression node.Node) *ShiftRight { return &ShiftRight{ - BinaryOp{ - Variable, - Expression, - }, + Variable, + Expression, } } diff --git a/node/expr/binary_op/n_smaller.go b/node/expr/binary_op/n_smaller.go index 735c4a3..6772d86 100644 --- a/node/expr/binary_op/n_smaller.go +++ b/node/expr/binary_op/n_smaller.go @@ -7,16 +7,15 @@ import ( // Smaller node type Smaller struct { - BinaryOp + Left node.Node + Right node.Node } // NewSmaller node constuctor func NewSmaller(Variable node.Node, Expression node.Node) *Smaller { return &Smaller{ - BinaryOp{ - Variable, - Expression, - }, + Variable, + Expression, } } diff --git a/node/expr/binary_op/n_smaller_or_equal.go b/node/expr/binary_op/n_smaller_or_equal.go index 397fd71..12c1475 100644 --- a/node/expr/binary_op/n_smaller_or_equal.go +++ b/node/expr/binary_op/n_smaller_or_equal.go @@ -7,16 +7,15 @@ import ( // SmallerOrEqual node type SmallerOrEqual struct { - BinaryOp + Left node.Node + Right node.Node } // NewSmallerOrEqual node constuctor func NewSmallerOrEqual(Variable node.Node, Expression node.Node) *SmallerOrEqual { return &SmallerOrEqual{ - BinaryOp{ - Variable, - Expression, - }, + Variable, + Expression, } } diff --git a/node/expr/binary_op/n_spaceship.go b/node/expr/binary_op/n_spaceship.go index 8eebbbf..4d57f7d 100644 --- a/node/expr/binary_op/n_spaceship.go +++ b/node/expr/binary_op/n_spaceship.go @@ -7,16 +7,15 @@ import ( // Spaceship node type Spaceship struct { - BinaryOp + Left node.Node + Right node.Node } // NewSpaceship node constuctor func NewSpaceship(Variable node.Node, Expression node.Node) *Spaceship { return &Spaceship{ - BinaryOp{ - Variable, - Expression, - }, + Variable, + Expression, } } diff --git a/node/expr/binary_op/t_binary_op_test.go b/node/expr/binary_op/t_binary_op_test.go index 46d8a1d..a8671cc 100644 --- a/node/expr/binary_op/t_binary_op_test.go +++ b/node/expr/binary_op/t_binary_op_test.go @@ -4,9 +4,9 @@ import ( "bytes" "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_op" @@ -34,10 +34,8 @@ func TestBitwiseAnd(t *testing.T) { Stmts: []node.Node{ &stmt.Expression{ Expr: &binary_op.BitwiseAnd{ - BinaryOp: binary_op.BinaryOp{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, - }, + Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, }, }, }, @@ -57,10 +55,8 @@ func TestBitwiseOr(t *testing.T) { Stmts: []node.Node{ &stmt.Expression{ Expr: &binary_op.BitwiseOr{ - BinaryOp: binary_op.BinaryOp{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, - }, + Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, }, }, }, @@ -80,10 +76,8 @@ func TestBitwiseXor(t *testing.T) { Stmts: []node.Node{ &stmt.Expression{ Expr: &binary_op.BitwiseXor{ - BinaryOp: binary_op.BinaryOp{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, - }, + Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, }, }, }, @@ -103,10 +97,8 @@ func TestBooleanAnd(t *testing.T) { Stmts: []node.Node{ &stmt.Expression{ Expr: &binary_op.BooleanAnd{ - BinaryOp: binary_op.BinaryOp{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, - }, + Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, }, }, }, @@ -126,10 +118,8 @@ func TestBooleanOr(t *testing.T) { Stmts: []node.Node{ &stmt.Expression{ Expr: &binary_op.BooleanOr{ - BinaryOp: binary_op.BinaryOp{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, - }, + Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, }, }, }, @@ -149,10 +139,8 @@ func TestCoalesce(t *testing.T) { Stmts: []node.Node{ &stmt.Expression{ Expr: &binary_op.Coalesce{ - BinaryOp: binary_op.BinaryOp{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, - }, + Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, }, }, }, @@ -169,10 +157,8 @@ func TestConcat(t *testing.T) { Stmts: []node.Node{ &stmt.Expression{ Expr: &binary_op.Concat{ - BinaryOp: binary_op.BinaryOp{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, - }, + Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, }, }, }, @@ -192,10 +178,8 @@ func TestDiv(t *testing.T) { Stmts: []node.Node{ &stmt.Expression{ Expr: &binary_op.Div{ - BinaryOp: binary_op.BinaryOp{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, - }, + Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, }, }, }, @@ -215,10 +199,8 @@ func TestEqual(t *testing.T) { Stmts: []node.Node{ &stmt.Expression{ Expr: &binary_op.Equal{ - BinaryOp: binary_op.BinaryOp{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, - }, + Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, }, }, }, @@ -238,10 +220,8 @@ func TestGreaterOrEqual(t *testing.T) { Stmts: []node.Node{ &stmt.Expression{ Expr: &binary_op.GreaterOrEqual{ - BinaryOp: binary_op.BinaryOp{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, - }, + Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, }, }, }, @@ -261,10 +241,8 @@ func TestGreater(t *testing.T) { Stmts: []node.Node{ &stmt.Expression{ Expr: &binary_op.Greater{ - BinaryOp: binary_op.BinaryOp{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, - }, + Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, }, }, }, @@ -284,10 +262,8 @@ func TestIdentical(t *testing.T) { Stmts: []node.Node{ &stmt.Expression{ Expr: &binary_op.Identical{ - BinaryOp: binary_op.BinaryOp{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, - }, + Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, }, }, }, @@ -307,10 +283,8 @@ func TestLogicalAnd(t *testing.T) { Stmts: []node.Node{ &stmt.Expression{ Expr: &binary_op.LogicalAnd{ - BinaryOp: binary_op.BinaryOp{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, - }, + Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, }, }, }, @@ -330,10 +304,8 @@ func TestLogicalOr(t *testing.T) { Stmts: []node.Node{ &stmt.Expression{ Expr: &binary_op.LogicalOr{ - BinaryOp: binary_op.BinaryOp{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, - }, + Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, }, }, }, @@ -353,10 +325,8 @@ func TestLogicalXor(t *testing.T) { Stmts: []node.Node{ &stmt.Expression{ Expr: &binary_op.LogicalXor{ - BinaryOp: binary_op.BinaryOp{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, - }, + Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, }, }, }, @@ -376,10 +346,8 @@ func TestMinus(t *testing.T) { Stmts: []node.Node{ &stmt.Expression{ Expr: &binary_op.Minus{ - BinaryOp: binary_op.BinaryOp{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, - }, + Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, }, }, }, @@ -399,10 +367,8 @@ func TestMod(t *testing.T) { Stmts: []node.Node{ &stmt.Expression{ Expr: &binary_op.Mod{ - BinaryOp: binary_op.BinaryOp{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, - }, + Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, }, }, }, @@ -422,10 +388,8 @@ func TestMul(t *testing.T) { Stmts: []node.Node{ &stmt.Expression{ Expr: &binary_op.Mul{ - BinaryOp: binary_op.BinaryOp{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, - }, + Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, }, }, }, @@ -445,10 +409,8 @@ func TestNotEqual(t *testing.T) { Stmts: []node.Node{ &stmt.Expression{ Expr: &binary_op.NotEqual{ - BinaryOp: binary_op.BinaryOp{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, - }, + Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, }, }, }, @@ -468,10 +430,8 @@ func TestNotIdentical(t *testing.T) { Stmts: []node.Node{ &stmt.Expression{ Expr: &binary_op.NotIdentical{ - BinaryOp: binary_op.BinaryOp{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, - }, + Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, }, }, }, @@ -491,10 +451,8 @@ func TestPlus(t *testing.T) { Stmts: []node.Node{ &stmt.Expression{ Expr: &binary_op.Plus{ - BinaryOp: binary_op.BinaryOp{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, - }, + Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, }, }, }, @@ -514,10 +472,8 @@ func TestPow(t *testing.T) { Stmts: []node.Node{ &stmt.Expression{ Expr: &binary_op.Pow{ - BinaryOp: binary_op.BinaryOp{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, - }, + Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, }, }, }, @@ -537,10 +493,8 @@ func TestShiftLeft(t *testing.T) { Stmts: []node.Node{ &stmt.Expression{ Expr: &binary_op.ShiftLeft{ - BinaryOp: binary_op.BinaryOp{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, - }, + Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, }, }, }, @@ -560,10 +514,8 @@ func TestShiftRight(t *testing.T) { Stmts: []node.Node{ &stmt.Expression{ Expr: &binary_op.ShiftRight{ - BinaryOp: binary_op.BinaryOp{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, - }, + Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, }, }, }, @@ -583,10 +535,8 @@ func TestSmallerOrEqual(t *testing.T) { Stmts: []node.Node{ &stmt.Expression{ Expr: &binary_op.SmallerOrEqual{ - BinaryOp: binary_op.BinaryOp{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, - }, + Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, }, }, }, @@ -606,10 +556,8 @@ func TestSmaller(t *testing.T) { Stmts: []node.Node{ &stmt.Expression{ Expr: &binary_op.Smaller{ - BinaryOp: binary_op.BinaryOp{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, - }, + Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, }, }, }, @@ -629,10 +577,8 @@ func TestSpaceship(t *testing.T) { Stmts: []node.Node{ &stmt.Expression{ Expr: &binary_op.Spaceship{ - BinaryOp: binary_op.BinaryOp{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, - }, + Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, }, }, }, diff --git a/node/expr/binary_op/t_visitor_test.go b/node/expr/binary_op/t_visitor_test.go index dfa084e..d365d12 100644 --- a/node/expr/binary_op/t_visitor_test.go +++ b/node/expr/binary_op/t_visitor_test.go @@ -3,9 +3,9 @@ package binary_op_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_op" @@ -19,270 +19,216 @@ var nodesToTest = []struct { }{ { &binary_op.BitwiseAnd{ - BinaryOp: binary_op.BinaryOp{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, - }, + Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, }, []string{"Left", "Right"}, map[string]interface{}{}, }, { &binary_op.BitwiseOr{ - BinaryOp: binary_op.BinaryOp{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, - }, + Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, }, []string{"Left", "Right"}, map[string]interface{}{}, }, { &binary_op.BitwiseXor{ - BinaryOp: binary_op.BinaryOp{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, - }, + Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, }, []string{"Left", "Right"}, map[string]interface{}{}, }, { &binary_op.BooleanAnd{ - BinaryOp: binary_op.BinaryOp{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, - }, + Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, }, []string{"Left", "Right"}, map[string]interface{}{}, }, { &binary_op.BooleanOr{ - BinaryOp: binary_op.BinaryOp{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, - }, + Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, }, []string{"Left", "Right"}, map[string]interface{}{}, }, { &binary_op.Coalesce{ - BinaryOp: binary_op.BinaryOp{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, - }, + Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, }, []string{"Left", "Right"}, map[string]interface{}{}, }, { &binary_op.Concat{ - BinaryOp: binary_op.BinaryOp{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, - }, + Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, }, []string{"Left", "Right"}, map[string]interface{}{}, }, { &binary_op.Div{ - BinaryOp: binary_op.BinaryOp{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, - }, + Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, }, []string{"Left", "Right"}, map[string]interface{}{}, }, { &binary_op.Equal{ - BinaryOp: binary_op.BinaryOp{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, - }, + Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, }, []string{"Left", "Right"}, map[string]interface{}{}, }, { &binary_op.GreaterOrEqual{ - BinaryOp: binary_op.BinaryOp{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, - }, + Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, }, []string{"Left", "Right"}, map[string]interface{}{}, }, { &binary_op.Greater{ - BinaryOp: binary_op.BinaryOp{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, - }, + Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, }, []string{"Left", "Right"}, map[string]interface{}{}, }, { &binary_op.Identical{ - BinaryOp: binary_op.BinaryOp{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, - }, + Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, }, []string{"Left", "Right"}, map[string]interface{}{}, }, { &binary_op.LogicalAnd{ - BinaryOp: binary_op.BinaryOp{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, - }, + Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, }, []string{"Left", "Right"}, map[string]interface{}{}, }, { &binary_op.LogicalOr{ - BinaryOp: binary_op.BinaryOp{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, - }, + Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, }, []string{"Left", "Right"}, map[string]interface{}{}, }, { &binary_op.LogicalXor{ - BinaryOp: binary_op.BinaryOp{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, - }, + Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, }, []string{"Left", "Right"}, map[string]interface{}{}, }, { &binary_op.Minus{ - BinaryOp: binary_op.BinaryOp{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, - }, + Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, }, []string{"Left", "Right"}, map[string]interface{}{}, }, { &binary_op.Mod{ - BinaryOp: binary_op.BinaryOp{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, - }, + Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, }, []string{"Left", "Right"}, map[string]interface{}{}, }, { &binary_op.Mul{ - BinaryOp: binary_op.BinaryOp{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, - }, + Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, }, []string{"Left", "Right"}, map[string]interface{}{}, }, { &binary_op.NotEqual{ - BinaryOp: binary_op.BinaryOp{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, - }, + Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, }, []string{"Left", "Right"}, map[string]interface{}{}, }, { &binary_op.NotIdentical{ - BinaryOp: binary_op.BinaryOp{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, - }, + Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, }, []string{"Left", "Right"}, map[string]interface{}{}, }, { &binary_op.Plus{ - BinaryOp: binary_op.BinaryOp{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, - }, + Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, }, []string{"Left", "Right"}, map[string]interface{}{}, }, { &binary_op.Pow{ - BinaryOp: binary_op.BinaryOp{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, - }, + Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, }, []string{"Left", "Right"}, map[string]interface{}{}, }, { &binary_op.ShiftLeft{ - BinaryOp: binary_op.BinaryOp{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, - }, + Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, }, []string{"Left", "Right"}, map[string]interface{}{}, }, { &binary_op.ShiftRight{ - BinaryOp: binary_op.BinaryOp{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, - }, + Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, }, []string{"Left", "Right"}, map[string]interface{}{}, }, { &binary_op.SmallerOrEqual{ - BinaryOp: binary_op.BinaryOp{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, - }, + Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, }, []string{"Left", "Right"}, map[string]interface{}{}, }, { &binary_op.Smaller{ - BinaryOp: binary_op.BinaryOp{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, - }, + Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, }, []string{"Left", "Right"}, map[string]interface{}{}, }, { &binary_op.Spaceship{ - BinaryOp: binary_op.BinaryOp{ - Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, - Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, - }, + Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, + Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}}, }, []string{"Left", "Right"}, map[string]interface{}{},