refactor binary_op nodes
This commit is contained in:
parent
03cffcc98b
commit
9dbc898d7f
@ -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
|
||||
}
|
@ -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,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,13 +34,11 @@ 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"}},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
actual, _, _ := php7.Parse(bytes.NewBufferString(src), "test.php")
|
||||
@ -57,13 +55,11 @@ 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"}},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
actual, _, _ := php7.Parse(bytes.NewBufferString(src), "test.php")
|
||||
@ -80,13 +76,11 @@ 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"}},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
actual, _, _ := php7.Parse(bytes.NewBufferString(src), "test.php")
|
||||
@ -103,13 +97,11 @@ 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"}},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
actual, _, _ := php7.Parse(bytes.NewBufferString(src), "test.php")
|
||||
@ -126,13 +118,11 @@ 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"}},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
actual, _, _ := php7.Parse(bytes.NewBufferString(src), "test.php")
|
||||
@ -149,13 +139,11 @@ 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"}},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
actual, _, _ := php7.Parse(bytes.NewBufferString(src), "test.php")
|
||||
@ -169,13 +157,11 @@ 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"}},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
actual, _, _ := php7.Parse(bytes.NewBufferString(src), "test.php")
|
||||
@ -192,13 +178,11 @@ 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"}},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
actual, _, _ := php7.Parse(bytes.NewBufferString(src), "test.php")
|
||||
@ -215,13 +199,11 @@ 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"}},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
actual, _, _ := php7.Parse(bytes.NewBufferString(src), "test.php")
|
||||
@ -238,13 +220,11 @@ 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"}},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
actual, _, _ := php7.Parse(bytes.NewBufferString(src), "test.php")
|
||||
@ -261,13 +241,11 @@ 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"}},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
actual, _, _ := php7.Parse(bytes.NewBufferString(src), "test.php")
|
||||
@ -284,13 +262,11 @@ 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"}},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
actual, _, _ := php7.Parse(bytes.NewBufferString(src), "test.php")
|
||||
@ -307,13 +283,11 @@ 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"}},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
actual, _, _ := php7.Parse(bytes.NewBufferString(src), "test.php")
|
||||
@ -330,13 +304,11 @@ 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"}},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
actual, _, _ := php7.Parse(bytes.NewBufferString(src), "test.php")
|
||||
@ -353,13 +325,11 @@ 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"}},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
actual, _, _ := php7.Parse(bytes.NewBufferString(src), "test.php")
|
||||
@ -376,13 +346,11 @@ 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"}},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
actual, _, _ := php7.Parse(bytes.NewBufferString(src), "test.php")
|
||||
@ -399,13 +367,11 @@ 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"}},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
actual, _, _ := php7.Parse(bytes.NewBufferString(src), "test.php")
|
||||
@ -422,13 +388,11 @@ 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"}},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
actual, _, _ := php7.Parse(bytes.NewBufferString(src), "test.php")
|
||||
@ -445,13 +409,11 @@ 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"}},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
actual, _, _ := php7.Parse(bytes.NewBufferString(src), "test.php")
|
||||
@ -468,13 +430,11 @@ 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"}},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
actual, _, _ := php7.Parse(bytes.NewBufferString(src), "test.php")
|
||||
@ -491,13 +451,11 @@ 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"}},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
actual, _, _ := php7.Parse(bytes.NewBufferString(src), "test.php")
|
||||
@ -514,13 +472,11 @@ 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"}},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
actual, _, _ := php7.Parse(bytes.NewBufferString(src), "test.php")
|
||||
@ -537,13 +493,11 @@ 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"}},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
actual, _, _ := php7.Parse(bytes.NewBufferString(src), "test.php")
|
||||
@ -560,13 +514,11 @@ 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"}},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
actual, _, _ := php7.Parse(bytes.NewBufferString(src), "test.php")
|
||||
@ -583,13 +535,11 @@ 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"}},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
actual, _, _ := php7.Parse(bytes.NewBufferString(src), "test.php")
|
||||
@ -606,13 +556,11 @@ 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"}},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
actual, _, _ := php7.Parse(bytes.NewBufferString(src), "test.php")
|
||||
@ -629,13 +577,11 @@ 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"}},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
actual, _, _ := php7.Parse(bytes.NewBufferString(src), "test.php")
|
||||
|
@ -19,271 +19,217 @@ 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"}},
|
||||
},
|
||||
},
|
||||
[]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"}},
|
||||
},
|
||||
},
|
||||
[]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"}},
|
||||
},
|
||||
},
|
||||
[]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"}},
|
||||
},
|
||||
},
|
||||
[]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"}},
|
||||
},
|
||||
},
|
||||
[]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"}},
|
||||
},
|
||||
},
|
||||
[]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"}},
|
||||
},
|
||||
},
|
||||
[]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"}},
|
||||
},
|
||||
},
|
||||
[]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"}},
|
||||
},
|
||||
},
|
||||
[]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"}},
|
||||
},
|
||||
},
|
||||
[]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"}},
|
||||
},
|
||||
},
|
||||
[]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"}},
|
||||
},
|
||||
},
|
||||
[]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"}},
|
||||
},
|
||||
},
|
||||
[]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"}},
|
||||
},
|
||||
},
|
||||
[]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"}},
|
||||
},
|
||||
},
|
||||
[]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"}},
|
||||
},
|
||||
},
|
||||
[]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"}},
|
||||
},
|
||||
},
|
||||
[]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"}},
|
||||
},
|
||||
},
|
||||
[]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"}},
|
||||
},
|
||||
},
|
||||
[]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"}},
|
||||
},
|
||||
},
|
||||
[]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"}},
|
||||
},
|
||||
},
|
||||
[]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"}},
|
||||
},
|
||||
},
|
||||
[]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"}},
|
||||
},
|
||||
},
|
||||
[]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"}},
|
||||
},
|
||||
},
|
||||
[]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"}},
|
||||
},
|
||||
},
|
||||
[]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"}},
|
||||
},
|
||||
},
|
||||
[]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"}},
|
||||
},
|
||||
},
|
||||
[]string{"Left", "Right"},
|
||||
map[string]interface{}{},
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user