refactor binary_op nodes

This commit is contained in:
z7zmey 2018-02-10 01:02:50 +02:00
parent 03cffcc98b
commit 9dbc898d7f
30 changed files with 220 additions and 366 deletions

View File

@ -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
}

View File

@ -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,
}
}

View File

@ -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,
}
}

View File

@ -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,
}
}

View File

@ -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,
}
}

View File

@ -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,
}
}

View File

@ -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,
}
}

View File

@ -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,
}
}

View File

@ -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,
}
}

View File

@ -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,
}
}

View File

@ -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,
}
}

View File

@ -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,
}
}

View File

@ -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,
}
}

View File

@ -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,
}
}

View File

@ -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,
}
}

View File

@ -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,
}
}

View File

@ -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,
}
}

View File

@ -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,
}
}

View File

@ -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,
}
}

View File

@ -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,
}
}

View File

@ -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,
}
}

View File

@ -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,
}
}

View File

@ -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,
}
}

View File

@ -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,
}
}

View File

@ -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,
}
}

View File

@ -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,
}
}

View File

@ -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,
}
}

View File

@ -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,
}
}

View File

@ -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"}},
},
},
},

View File

@ -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{}{},