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 // BitwiseAnd node
type BitwiseAnd struct { type BitwiseAnd struct {
BinaryOp Left node.Node
Right node.Node
} }
// NewBitwiseAnd node constuctor // NewBitwiseAnd node constuctor
func NewBitwiseAnd(Variable node.Node, Expression node.Node) *BitwiseAnd { func NewBitwiseAnd(Variable node.Node, Expression node.Node) *BitwiseAnd {
return &BitwiseAnd{ return &BitwiseAnd{
BinaryOp{ Variable,
Variable, Expression,
Expression,
},
} }
} }

View File

@ -7,16 +7,15 @@ import (
// BitwiseOr node // BitwiseOr node
type BitwiseOr struct { type BitwiseOr struct {
BinaryOp Left node.Node
Right node.Node
} }
// NewBitwiseOr node constuctor // NewBitwiseOr node constuctor
func NewBitwiseOr(Variable node.Node, Expression node.Node) *BitwiseOr { func NewBitwiseOr(Variable node.Node, Expression node.Node) *BitwiseOr {
return &BitwiseOr{ return &BitwiseOr{
BinaryOp{ Variable,
Variable, Expression,
Expression,
},
} }
} }

View File

@ -7,16 +7,15 @@ import (
// BitwiseXor node // BitwiseXor node
type BitwiseXor struct { type BitwiseXor struct {
BinaryOp Left node.Node
Right node.Node
} }
// NewBitwiseXor node constuctor // NewBitwiseXor node constuctor
func NewBitwiseXor(Variable node.Node, Expression node.Node) *BitwiseXor { func NewBitwiseXor(Variable node.Node, Expression node.Node) *BitwiseXor {
return &BitwiseXor{ return &BitwiseXor{
BinaryOp{ Variable,
Variable, Expression,
Expression,
},
} }
} }

View File

@ -7,16 +7,15 @@ import (
// BooleanAnd node // BooleanAnd node
type BooleanAnd struct { type BooleanAnd struct {
BinaryOp Left node.Node
Right node.Node
} }
// NewBooleanAnd node constuctor // NewBooleanAnd node constuctor
func NewBooleanAnd(Variable node.Node, Expression node.Node) *BooleanAnd { func NewBooleanAnd(Variable node.Node, Expression node.Node) *BooleanAnd {
return &BooleanAnd{ return &BooleanAnd{
BinaryOp{ Variable,
Variable, Expression,
Expression,
},
} }
} }

View File

@ -7,16 +7,15 @@ import (
// BooleanOr node // BooleanOr node
type BooleanOr struct { type BooleanOr struct {
BinaryOp Left node.Node
Right node.Node
} }
// NewBooleanOr node constuctor // NewBooleanOr node constuctor
func NewBooleanOr(Variable node.Node, Expression node.Node) *BooleanOr { func NewBooleanOr(Variable node.Node, Expression node.Node) *BooleanOr {
return &BooleanOr{ return &BooleanOr{
BinaryOp{ Variable,
Variable, Expression,
Expression,
},
} }
} }

View File

@ -7,16 +7,15 @@ import (
// Coalesce node // Coalesce node
type Coalesce struct { type Coalesce struct {
BinaryOp Left node.Node
Right node.Node
} }
// NewCoalesce node constuctor // NewCoalesce node constuctor
func NewCoalesce(Variable node.Node, Expression node.Node) *Coalesce { func NewCoalesce(Variable node.Node, Expression node.Node) *Coalesce {
return &Coalesce{ return &Coalesce{
BinaryOp{ Variable,
Variable, Expression,
Expression,
},
} }
} }

View File

@ -7,16 +7,15 @@ import (
// Concat node // Concat node
type Concat struct { type Concat struct {
BinaryOp Left node.Node
Right node.Node
} }
// NewConcat node constuctor // NewConcat node constuctor
func NewConcat(Variable node.Node, Expression node.Node) *Concat { func NewConcat(Variable node.Node, Expression node.Node) *Concat {
return &Concat{ return &Concat{
BinaryOp{ Variable,
Variable, Expression,
Expression,
},
} }
} }

View File

@ -7,16 +7,15 @@ import (
// Div node // Div node
type Div struct { type Div struct {
BinaryOp Left node.Node
Right node.Node
} }
// NewDiv node constuctor // NewDiv node constuctor
func NewDiv(Variable node.Node, Expression node.Node) *Div { func NewDiv(Variable node.Node, Expression node.Node) *Div {
return &Div{ return &Div{
BinaryOp{ Variable,
Variable, Expression,
Expression,
},
} }
} }

View File

@ -7,16 +7,15 @@ import (
// Equal node // Equal node
type Equal struct { type Equal struct {
BinaryOp Left node.Node
Right node.Node
} }
// NewEqual node constuctor // NewEqual node constuctor
func NewEqual(Variable node.Node, Expression node.Node) *Equal { func NewEqual(Variable node.Node, Expression node.Node) *Equal {
return &Equal{ return &Equal{
BinaryOp{ Variable,
Variable, Expression,
Expression,
},
} }
} }

View File

@ -7,16 +7,15 @@ import (
// Greater node // Greater node
type Greater struct { type Greater struct {
BinaryOp Left node.Node
Right node.Node
} }
// NewGreater node constuctor // NewGreater node constuctor
func NewGreater(Variable node.Node, Expression node.Node) *Greater { func NewGreater(Variable node.Node, Expression node.Node) *Greater {
return &Greater{ return &Greater{
BinaryOp{ Variable,
Variable, Expression,
Expression,
},
} }
} }

View File

@ -7,16 +7,15 @@ import (
// GreaterOrEqual node // GreaterOrEqual node
type GreaterOrEqual struct { type GreaterOrEqual struct {
BinaryOp Left node.Node
Right node.Node
} }
// NewGreaterOrEqual node constuctor // NewGreaterOrEqual node constuctor
func NewGreaterOrEqual(Variable node.Node, Expression node.Node) *GreaterOrEqual { func NewGreaterOrEqual(Variable node.Node, Expression node.Node) *GreaterOrEqual {
return &GreaterOrEqual{ return &GreaterOrEqual{
BinaryOp{ Variable,
Variable, Expression,
Expression,
},
} }
} }

View File

@ -7,16 +7,15 @@ import (
// Identical node // Identical node
type Identical struct { type Identical struct {
BinaryOp Left node.Node
Right node.Node
} }
// NewIdentical node constuctor // NewIdentical node constuctor
func NewIdentical(Variable node.Node, Expression node.Node) *Identical { func NewIdentical(Variable node.Node, Expression node.Node) *Identical {
return &Identical{ return &Identical{
BinaryOp{ Variable,
Variable, Expression,
Expression,
},
} }
} }

View File

@ -7,16 +7,15 @@ import (
// LogicalAnd node // LogicalAnd node
type LogicalAnd struct { type LogicalAnd struct {
BinaryOp Left node.Node
Right node.Node
} }
// NewLogicalAnd node constuctor // NewLogicalAnd node constuctor
func NewLogicalAnd(Variable node.Node, Expression node.Node) *LogicalAnd { func NewLogicalAnd(Variable node.Node, Expression node.Node) *LogicalAnd {
return &LogicalAnd{ return &LogicalAnd{
BinaryOp{ Variable,
Variable, Expression,
Expression,
},
} }
} }

View File

@ -7,16 +7,15 @@ import (
// LogicalOr node // LogicalOr node
type LogicalOr struct { type LogicalOr struct {
BinaryOp Left node.Node
Right node.Node
} }
// NewLogicalOr node constuctor // NewLogicalOr node constuctor
func NewLogicalOr(Variable node.Node, Expression node.Node) *LogicalOr { func NewLogicalOr(Variable node.Node, Expression node.Node) *LogicalOr {
return &LogicalOr{ return &LogicalOr{
BinaryOp{ Variable,
Variable, Expression,
Expression,
},
} }
} }

View File

@ -7,16 +7,15 @@ import (
// LogicalXor node // LogicalXor node
type LogicalXor struct { type LogicalXor struct {
BinaryOp Left node.Node
Right node.Node
} }
// NewLogicalXor node constuctor // NewLogicalXor node constuctor
func NewLogicalXor(Variable node.Node, Expression node.Node) *LogicalXor { func NewLogicalXor(Variable node.Node, Expression node.Node) *LogicalXor {
return &LogicalXor{ return &LogicalXor{
BinaryOp{ Variable,
Variable, Expression,
Expression,
},
} }
} }

View File

@ -7,16 +7,15 @@ import (
// Minus node // Minus node
type Minus struct { type Minus struct {
BinaryOp Left node.Node
Right node.Node
} }
// NewMinus node constuctor // NewMinus node constuctor
func NewMinus(Variable node.Node, Expression node.Node) *Minus { func NewMinus(Variable node.Node, Expression node.Node) *Minus {
return &Minus{ return &Minus{
BinaryOp{ Variable,
Variable, Expression,
Expression,
},
} }
} }

View File

@ -7,16 +7,15 @@ import (
// Mod node // Mod node
type Mod struct { type Mod struct {
BinaryOp Left node.Node
Right node.Node
} }
// NewMod node constuctor // NewMod node constuctor
func NewMod(Variable node.Node, Expression node.Node) *Mod { func NewMod(Variable node.Node, Expression node.Node) *Mod {
return &Mod{ return &Mod{
BinaryOp{ Variable,
Variable, Expression,
Expression,
},
} }
} }

View File

@ -7,16 +7,15 @@ import (
// Mul node // Mul node
type Mul struct { type Mul struct {
BinaryOp Left node.Node
Right node.Node
} }
// NewMul node constuctor // NewMul node constuctor
func NewMul(Variable node.Node, Expression node.Node) *Mul { func NewMul(Variable node.Node, Expression node.Node) *Mul {
return &Mul{ return &Mul{
BinaryOp{ Variable,
Variable, Expression,
Expression,
},
} }
} }

View File

@ -7,16 +7,15 @@ import (
// NotEqual node // NotEqual node
type NotEqual struct { type NotEqual struct {
BinaryOp Left node.Node
Right node.Node
} }
// NewNotEqual node constuctor // NewNotEqual node constuctor
func NewNotEqual(Variable node.Node, Expression node.Node) *NotEqual { func NewNotEqual(Variable node.Node, Expression node.Node) *NotEqual {
return &NotEqual{ return &NotEqual{
BinaryOp{ Variable,
Variable, Expression,
Expression,
},
} }
} }

View File

@ -7,16 +7,15 @@ import (
// NotIdentical node // NotIdentical node
type NotIdentical struct { type NotIdentical struct {
BinaryOp Left node.Node
Right node.Node
} }
// NewNotIdentical node constuctor // NewNotIdentical node constuctor
func NewNotIdentical(Variable node.Node, Expression node.Node) *NotIdentical { func NewNotIdentical(Variable node.Node, Expression node.Node) *NotIdentical {
return &NotIdentical{ return &NotIdentical{
BinaryOp{ Variable,
Variable, Expression,
Expression,
},
} }
} }

View File

@ -7,16 +7,15 @@ import (
// Plus node // Plus node
type Plus struct { type Plus struct {
BinaryOp Left node.Node
Right node.Node
} }
// NewPlus node constuctor // NewPlus node constuctor
func NewPlus(Variable node.Node, Expression node.Node) *Plus { func NewPlus(Variable node.Node, Expression node.Node) *Plus {
return &Plus{ return &Plus{
BinaryOp{ Variable,
Variable, Expression,
Expression,
},
} }
} }

View File

@ -7,16 +7,15 @@ import (
// Pow node // Pow node
type Pow struct { type Pow struct {
BinaryOp Left node.Node
Right node.Node
} }
// NewPow node constuctor // NewPow node constuctor
func NewPow(Variable node.Node, Expression node.Node) *Pow { func NewPow(Variable node.Node, Expression node.Node) *Pow {
return &Pow{ return &Pow{
BinaryOp{ Variable,
Variable, Expression,
Expression,
},
} }
} }

View File

@ -7,16 +7,15 @@ import (
// ShiftLeft node // ShiftLeft node
type ShiftLeft struct { type ShiftLeft struct {
BinaryOp Left node.Node
Right node.Node
} }
// NewShiftLeft node constuctor // NewShiftLeft node constuctor
func NewShiftLeft(Variable node.Node, Expression node.Node) *ShiftLeft { func NewShiftLeft(Variable node.Node, Expression node.Node) *ShiftLeft {
return &ShiftLeft{ return &ShiftLeft{
BinaryOp{ Variable,
Variable, Expression,
Expression,
},
} }
} }

View File

@ -7,16 +7,15 @@ import (
// ShiftRight node // ShiftRight node
type ShiftRight struct { type ShiftRight struct {
BinaryOp Left node.Node
Right node.Node
} }
// NewShiftRight node constuctor // NewShiftRight node constuctor
func NewShiftRight(Variable node.Node, Expression node.Node) *ShiftRight { func NewShiftRight(Variable node.Node, Expression node.Node) *ShiftRight {
return &ShiftRight{ return &ShiftRight{
BinaryOp{ Variable,
Variable, Expression,
Expression,
},
} }
} }

View File

@ -7,16 +7,15 @@ import (
// Smaller node // Smaller node
type Smaller struct { type Smaller struct {
BinaryOp Left node.Node
Right node.Node
} }
// NewSmaller node constuctor // NewSmaller node constuctor
func NewSmaller(Variable node.Node, Expression node.Node) *Smaller { func NewSmaller(Variable node.Node, Expression node.Node) *Smaller {
return &Smaller{ return &Smaller{
BinaryOp{ Variable,
Variable, Expression,
Expression,
},
} }
} }

View File

@ -7,16 +7,15 @@ import (
// SmallerOrEqual node // SmallerOrEqual node
type SmallerOrEqual struct { type SmallerOrEqual struct {
BinaryOp Left node.Node
Right node.Node
} }
// NewSmallerOrEqual node constuctor // NewSmallerOrEqual node constuctor
func NewSmallerOrEqual(Variable node.Node, Expression node.Node) *SmallerOrEqual { func NewSmallerOrEqual(Variable node.Node, Expression node.Node) *SmallerOrEqual {
return &SmallerOrEqual{ return &SmallerOrEqual{
BinaryOp{ Variable,
Variable, Expression,
Expression,
},
} }
} }

View File

@ -7,16 +7,15 @@ import (
// Spaceship node // Spaceship node
type Spaceship struct { type Spaceship struct {
BinaryOp Left node.Node
Right node.Node
} }
// NewSpaceship node constuctor // NewSpaceship node constuctor
func NewSpaceship(Variable node.Node, Expression node.Node) *Spaceship { func NewSpaceship(Variable node.Node, Expression node.Node) *Spaceship {
return &Spaceship{ return &Spaceship{
BinaryOp{ Variable,
Variable, Expression,
Expression,
},
} }
} }

View File

@ -4,9 +4,9 @@ import (
"bytes" "bytes"
"reflect" "reflect"
"testing" "testing"
"github.com/kylelemons/godebug/pretty" "github.com/kylelemons/godebug/pretty"
"github.com/z7zmey/php-parser/node" "github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/node/expr" "github.com/z7zmey/php-parser/node/expr"
"github.com/z7zmey/php-parser/node/expr/binary_op" "github.com/z7zmey/php-parser/node/expr/binary_op"
@ -34,10 +34,8 @@ func TestBitwiseAnd(t *testing.T) {
Stmts: []node.Node{ Stmts: []node.Node{
&stmt.Expression{ &stmt.Expression{
Expr: &binary_op.BitwiseAnd{ Expr: &binary_op.BitwiseAnd{
BinaryOp: binary_op.BinaryOp{ Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
},
}, },
}, },
}, },
@ -57,10 +55,8 @@ func TestBitwiseOr(t *testing.T) {
Stmts: []node.Node{ Stmts: []node.Node{
&stmt.Expression{ &stmt.Expression{
Expr: &binary_op.BitwiseOr{ Expr: &binary_op.BitwiseOr{
BinaryOp: binary_op.BinaryOp{ Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
},
}, },
}, },
}, },
@ -80,10 +76,8 @@ func TestBitwiseXor(t *testing.T) {
Stmts: []node.Node{ Stmts: []node.Node{
&stmt.Expression{ &stmt.Expression{
Expr: &binary_op.BitwiseXor{ Expr: &binary_op.BitwiseXor{
BinaryOp: binary_op.BinaryOp{ Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
},
}, },
}, },
}, },
@ -103,10 +97,8 @@ func TestBooleanAnd(t *testing.T) {
Stmts: []node.Node{ Stmts: []node.Node{
&stmt.Expression{ &stmt.Expression{
Expr: &binary_op.BooleanAnd{ Expr: &binary_op.BooleanAnd{
BinaryOp: binary_op.BinaryOp{ Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
},
}, },
}, },
}, },
@ -126,10 +118,8 @@ func TestBooleanOr(t *testing.T) {
Stmts: []node.Node{ Stmts: []node.Node{
&stmt.Expression{ &stmt.Expression{
Expr: &binary_op.BooleanOr{ Expr: &binary_op.BooleanOr{
BinaryOp: binary_op.BinaryOp{ Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
},
}, },
}, },
}, },
@ -149,10 +139,8 @@ func TestCoalesce(t *testing.T) {
Stmts: []node.Node{ Stmts: []node.Node{
&stmt.Expression{ &stmt.Expression{
Expr: &binary_op.Coalesce{ Expr: &binary_op.Coalesce{
BinaryOp: binary_op.BinaryOp{ Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
},
}, },
}, },
}, },
@ -169,10 +157,8 @@ func TestConcat(t *testing.T) {
Stmts: []node.Node{ Stmts: []node.Node{
&stmt.Expression{ &stmt.Expression{
Expr: &binary_op.Concat{ Expr: &binary_op.Concat{
BinaryOp: binary_op.BinaryOp{ Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
},
}, },
}, },
}, },
@ -192,10 +178,8 @@ func TestDiv(t *testing.T) {
Stmts: []node.Node{ Stmts: []node.Node{
&stmt.Expression{ &stmt.Expression{
Expr: &binary_op.Div{ Expr: &binary_op.Div{
BinaryOp: binary_op.BinaryOp{ Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
},
}, },
}, },
}, },
@ -215,10 +199,8 @@ func TestEqual(t *testing.T) {
Stmts: []node.Node{ Stmts: []node.Node{
&stmt.Expression{ &stmt.Expression{
Expr: &binary_op.Equal{ Expr: &binary_op.Equal{
BinaryOp: binary_op.BinaryOp{ Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
},
}, },
}, },
}, },
@ -238,10 +220,8 @@ func TestGreaterOrEqual(t *testing.T) {
Stmts: []node.Node{ Stmts: []node.Node{
&stmt.Expression{ &stmt.Expression{
Expr: &binary_op.GreaterOrEqual{ Expr: &binary_op.GreaterOrEqual{
BinaryOp: binary_op.BinaryOp{ Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
},
}, },
}, },
}, },
@ -261,10 +241,8 @@ func TestGreater(t *testing.T) {
Stmts: []node.Node{ Stmts: []node.Node{
&stmt.Expression{ &stmt.Expression{
Expr: &binary_op.Greater{ Expr: &binary_op.Greater{
BinaryOp: binary_op.BinaryOp{ Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
},
}, },
}, },
}, },
@ -284,10 +262,8 @@ func TestIdentical(t *testing.T) {
Stmts: []node.Node{ Stmts: []node.Node{
&stmt.Expression{ &stmt.Expression{
Expr: &binary_op.Identical{ Expr: &binary_op.Identical{
BinaryOp: binary_op.BinaryOp{ Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
},
}, },
}, },
}, },
@ -307,10 +283,8 @@ func TestLogicalAnd(t *testing.T) {
Stmts: []node.Node{ Stmts: []node.Node{
&stmt.Expression{ &stmt.Expression{
Expr: &binary_op.LogicalAnd{ Expr: &binary_op.LogicalAnd{
BinaryOp: binary_op.BinaryOp{ Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
},
}, },
}, },
}, },
@ -330,10 +304,8 @@ func TestLogicalOr(t *testing.T) {
Stmts: []node.Node{ Stmts: []node.Node{
&stmt.Expression{ &stmt.Expression{
Expr: &binary_op.LogicalOr{ Expr: &binary_op.LogicalOr{
BinaryOp: binary_op.BinaryOp{ Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
},
}, },
}, },
}, },
@ -353,10 +325,8 @@ func TestLogicalXor(t *testing.T) {
Stmts: []node.Node{ Stmts: []node.Node{
&stmt.Expression{ &stmt.Expression{
Expr: &binary_op.LogicalXor{ Expr: &binary_op.LogicalXor{
BinaryOp: binary_op.BinaryOp{ Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
},
}, },
}, },
}, },
@ -376,10 +346,8 @@ func TestMinus(t *testing.T) {
Stmts: []node.Node{ Stmts: []node.Node{
&stmt.Expression{ &stmt.Expression{
Expr: &binary_op.Minus{ Expr: &binary_op.Minus{
BinaryOp: binary_op.BinaryOp{ Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
},
}, },
}, },
}, },
@ -399,10 +367,8 @@ func TestMod(t *testing.T) {
Stmts: []node.Node{ Stmts: []node.Node{
&stmt.Expression{ &stmt.Expression{
Expr: &binary_op.Mod{ Expr: &binary_op.Mod{
BinaryOp: binary_op.BinaryOp{ Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
},
}, },
}, },
}, },
@ -422,10 +388,8 @@ func TestMul(t *testing.T) {
Stmts: []node.Node{ Stmts: []node.Node{
&stmt.Expression{ &stmt.Expression{
Expr: &binary_op.Mul{ Expr: &binary_op.Mul{
BinaryOp: binary_op.BinaryOp{ Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
},
}, },
}, },
}, },
@ -445,10 +409,8 @@ func TestNotEqual(t *testing.T) {
Stmts: []node.Node{ Stmts: []node.Node{
&stmt.Expression{ &stmt.Expression{
Expr: &binary_op.NotEqual{ Expr: &binary_op.NotEqual{
BinaryOp: binary_op.BinaryOp{ Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
},
}, },
}, },
}, },
@ -468,10 +430,8 @@ func TestNotIdentical(t *testing.T) {
Stmts: []node.Node{ Stmts: []node.Node{
&stmt.Expression{ &stmt.Expression{
Expr: &binary_op.NotIdentical{ Expr: &binary_op.NotIdentical{
BinaryOp: binary_op.BinaryOp{ Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
},
}, },
}, },
}, },
@ -491,10 +451,8 @@ func TestPlus(t *testing.T) {
Stmts: []node.Node{ Stmts: []node.Node{
&stmt.Expression{ &stmt.Expression{
Expr: &binary_op.Plus{ Expr: &binary_op.Plus{
BinaryOp: binary_op.BinaryOp{ Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
},
}, },
}, },
}, },
@ -514,10 +472,8 @@ func TestPow(t *testing.T) {
Stmts: []node.Node{ Stmts: []node.Node{
&stmt.Expression{ &stmt.Expression{
Expr: &binary_op.Pow{ Expr: &binary_op.Pow{
BinaryOp: binary_op.BinaryOp{ Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
},
}, },
}, },
}, },
@ -537,10 +493,8 @@ func TestShiftLeft(t *testing.T) {
Stmts: []node.Node{ Stmts: []node.Node{
&stmt.Expression{ &stmt.Expression{
Expr: &binary_op.ShiftLeft{ Expr: &binary_op.ShiftLeft{
BinaryOp: binary_op.BinaryOp{ Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
},
}, },
}, },
}, },
@ -560,10 +514,8 @@ func TestShiftRight(t *testing.T) {
Stmts: []node.Node{ Stmts: []node.Node{
&stmt.Expression{ &stmt.Expression{
Expr: &binary_op.ShiftRight{ Expr: &binary_op.ShiftRight{
BinaryOp: binary_op.BinaryOp{ Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
},
}, },
}, },
}, },
@ -583,10 +535,8 @@ func TestSmallerOrEqual(t *testing.T) {
Stmts: []node.Node{ Stmts: []node.Node{
&stmt.Expression{ &stmt.Expression{
Expr: &binary_op.SmallerOrEqual{ Expr: &binary_op.SmallerOrEqual{
BinaryOp: binary_op.BinaryOp{ Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
},
}, },
}, },
}, },
@ -606,10 +556,8 @@ func TestSmaller(t *testing.T) {
Stmts: []node.Node{ Stmts: []node.Node{
&stmt.Expression{ &stmt.Expression{
Expr: &binary_op.Smaller{ Expr: &binary_op.Smaller{
BinaryOp: binary_op.BinaryOp{ Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
},
}, },
}, },
}, },
@ -629,10 +577,8 @@ func TestSpaceship(t *testing.T) {
Stmts: []node.Node{ Stmts: []node.Node{
&stmt.Expression{ &stmt.Expression{
Expr: &binary_op.Spaceship{ Expr: &binary_op.Spaceship{
BinaryOp: binary_op.BinaryOp{ Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
},
}, },
}, },
}, },

View File

@ -3,9 +3,9 @@ package binary_op_test
import ( import (
"reflect" "reflect"
"testing" "testing"
"github.com/kylelemons/godebug/pretty" "github.com/kylelemons/godebug/pretty"
"github.com/z7zmey/php-parser/node" "github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/node/expr" "github.com/z7zmey/php-parser/node/expr"
"github.com/z7zmey/php-parser/node/expr/binary_op" "github.com/z7zmey/php-parser/node/expr/binary_op"
@ -19,270 +19,216 @@ var nodesToTest = []struct {
}{ }{
{ {
&binary_op.BitwiseAnd{ &binary_op.BitwiseAnd{
BinaryOp: binary_op.BinaryOp{ Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
},
}, },
[]string{"Left", "Right"}, []string{"Left", "Right"},
map[string]interface{}{}, map[string]interface{}{},
}, },
{ {
&binary_op.BitwiseOr{ &binary_op.BitwiseOr{
BinaryOp: binary_op.BinaryOp{ Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
},
}, },
[]string{"Left", "Right"}, []string{"Left", "Right"},
map[string]interface{}{}, map[string]interface{}{},
}, },
{ {
&binary_op.BitwiseXor{ &binary_op.BitwiseXor{
BinaryOp: binary_op.BinaryOp{ Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
},
}, },
[]string{"Left", "Right"}, []string{"Left", "Right"},
map[string]interface{}{}, map[string]interface{}{},
}, },
{ {
&binary_op.BooleanAnd{ &binary_op.BooleanAnd{
BinaryOp: binary_op.BinaryOp{ Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
},
}, },
[]string{"Left", "Right"}, []string{"Left", "Right"},
map[string]interface{}{}, map[string]interface{}{},
}, },
{ {
&binary_op.BooleanOr{ &binary_op.BooleanOr{
BinaryOp: binary_op.BinaryOp{ Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
},
}, },
[]string{"Left", "Right"}, []string{"Left", "Right"},
map[string]interface{}{}, map[string]interface{}{},
}, },
{ {
&binary_op.Coalesce{ &binary_op.Coalesce{
BinaryOp: binary_op.BinaryOp{ Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
},
}, },
[]string{"Left", "Right"}, []string{"Left", "Right"},
map[string]interface{}{}, map[string]interface{}{},
}, },
{ {
&binary_op.Concat{ &binary_op.Concat{
BinaryOp: binary_op.BinaryOp{ Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
},
}, },
[]string{"Left", "Right"}, []string{"Left", "Right"},
map[string]interface{}{}, map[string]interface{}{},
}, },
{ {
&binary_op.Div{ &binary_op.Div{
BinaryOp: binary_op.BinaryOp{ Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
},
}, },
[]string{"Left", "Right"}, []string{"Left", "Right"},
map[string]interface{}{}, map[string]interface{}{},
}, },
{ {
&binary_op.Equal{ &binary_op.Equal{
BinaryOp: binary_op.BinaryOp{ Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
},
}, },
[]string{"Left", "Right"}, []string{"Left", "Right"},
map[string]interface{}{}, map[string]interface{}{},
}, },
{ {
&binary_op.GreaterOrEqual{ &binary_op.GreaterOrEqual{
BinaryOp: binary_op.BinaryOp{ Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
},
}, },
[]string{"Left", "Right"}, []string{"Left", "Right"},
map[string]interface{}{}, map[string]interface{}{},
}, },
{ {
&binary_op.Greater{ &binary_op.Greater{
BinaryOp: binary_op.BinaryOp{ Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
},
}, },
[]string{"Left", "Right"}, []string{"Left", "Right"},
map[string]interface{}{}, map[string]interface{}{},
}, },
{ {
&binary_op.Identical{ &binary_op.Identical{
BinaryOp: binary_op.BinaryOp{ Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
},
}, },
[]string{"Left", "Right"}, []string{"Left", "Right"},
map[string]interface{}{}, map[string]interface{}{},
}, },
{ {
&binary_op.LogicalAnd{ &binary_op.LogicalAnd{
BinaryOp: binary_op.BinaryOp{ Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
},
}, },
[]string{"Left", "Right"}, []string{"Left", "Right"},
map[string]interface{}{}, map[string]interface{}{},
}, },
{ {
&binary_op.LogicalOr{ &binary_op.LogicalOr{
BinaryOp: binary_op.BinaryOp{ Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
},
}, },
[]string{"Left", "Right"}, []string{"Left", "Right"},
map[string]interface{}{}, map[string]interface{}{},
}, },
{ {
&binary_op.LogicalXor{ &binary_op.LogicalXor{
BinaryOp: binary_op.BinaryOp{ Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
},
}, },
[]string{"Left", "Right"}, []string{"Left", "Right"},
map[string]interface{}{}, map[string]interface{}{},
}, },
{ {
&binary_op.Minus{ &binary_op.Minus{
BinaryOp: binary_op.BinaryOp{ Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
},
}, },
[]string{"Left", "Right"}, []string{"Left", "Right"},
map[string]interface{}{}, map[string]interface{}{},
}, },
{ {
&binary_op.Mod{ &binary_op.Mod{
BinaryOp: binary_op.BinaryOp{ Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
},
}, },
[]string{"Left", "Right"}, []string{"Left", "Right"},
map[string]interface{}{}, map[string]interface{}{},
}, },
{ {
&binary_op.Mul{ &binary_op.Mul{
BinaryOp: binary_op.BinaryOp{ Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
},
}, },
[]string{"Left", "Right"}, []string{"Left", "Right"},
map[string]interface{}{}, map[string]interface{}{},
}, },
{ {
&binary_op.NotEqual{ &binary_op.NotEqual{
BinaryOp: binary_op.BinaryOp{ Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
},
}, },
[]string{"Left", "Right"}, []string{"Left", "Right"},
map[string]interface{}{}, map[string]interface{}{},
}, },
{ {
&binary_op.NotIdentical{ &binary_op.NotIdentical{
BinaryOp: binary_op.BinaryOp{ Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
},
}, },
[]string{"Left", "Right"}, []string{"Left", "Right"},
map[string]interface{}{}, map[string]interface{}{},
}, },
{ {
&binary_op.Plus{ &binary_op.Plus{
BinaryOp: binary_op.BinaryOp{ Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
},
}, },
[]string{"Left", "Right"}, []string{"Left", "Right"},
map[string]interface{}{}, map[string]interface{}{},
}, },
{ {
&binary_op.Pow{ &binary_op.Pow{
BinaryOp: binary_op.BinaryOp{ Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
},
}, },
[]string{"Left", "Right"}, []string{"Left", "Right"},
map[string]interface{}{}, map[string]interface{}{},
}, },
{ {
&binary_op.ShiftLeft{ &binary_op.ShiftLeft{
BinaryOp: binary_op.BinaryOp{ Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
},
}, },
[]string{"Left", "Right"}, []string{"Left", "Right"},
map[string]interface{}{}, map[string]interface{}{},
}, },
{ {
&binary_op.ShiftRight{ &binary_op.ShiftRight{
BinaryOp: binary_op.BinaryOp{ Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
},
}, },
[]string{"Left", "Right"}, []string{"Left", "Right"},
map[string]interface{}{}, map[string]interface{}{},
}, },
{ {
&binary_op.SmallerOrEqual{ &binary_op.SmallerOrEqual{
BinaryOp: binary_op.BinaryOp{ Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
},
}, },
[]string{"Left", "Right"}, []string{"Left", "Right"},
map[string]interface{}{}, map[string]interface{}{},
}, },
{ {
&binary_op.Smaller{ &binary_op.Smaller{
BinaryOp: binary_op.BinaryOp{ Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
},
}, },
[]string{"Left", "Right"}, []string{"Left", "Right"},
map[string]interface{}{}, map[string]interface{}{},
}, },
{ {
&binary_op.Spaceship{ &binary_op.Spaceship{
BinaryOp: binary_op.BinaryOp{ Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
Left: &expr.Variable{VarName: &node.Identifier{Value: "$a"}}, Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
Right: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
},
}, },
[]string{"Left", "Right"}, []string{"Left", "Right"},
map[string]interface{}{}, map[string]interface{}{},