MCPcopy Index your code
hub / github.com/sql-machine-learning/sqlflow / TestBinary

Function TestBinary

go/parser/ast/expr_test.go:93–125  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

91}
92
93func TestBinary(t *testing.T) {
94 b, e := NewBinary('+', "+", nil, literalOrDie(1, "2"))
95 assert.Nil(t, b)
96 assert.Error(t, e)
97
98 b, e = NewBinary('-', "-", literalOrDie(1, "2"), nil)
99 assert.Nil(t, b)
100 assert.Error(t, e)
101
102 b, e = NewBinary('+', "+", literalOrDie(1, "1"), literalOrDie(1, "2"))
103 assert.NotNil(t, b)
104 assert.NoError(t, e)
105
106 assert.False(t, b.IsLiteral())
107 assert.False(t, b.IsFuncall())
108 assert.True(t, b.IsBinary())
109 assert.False(t, b.IsUnary())
110 assert.False(t, b.IsVariadic())
111
112 assert.Equal(t, "1 + 2", b.String())
113
114 b, e = NewBinary('+', "+", literalOrDie(1, "3"), b)
115 assert.NotNil(t, b)
116 assert.NoError(t, e)
117
118 assert.False(t, b.IsLiteral())
119 assert.False(t, b.IsFuncall())
120 assert.True(t, b.IsBinary())
121 assert.False(t, b.IsUnary())
122 assert.False(t, b.IsVariadic())
123
124 assert.Equal(t, "3 + 1 + 2", b.String())
125}
126
127func TestVariadic(t *testing.T) {
128 v, e := NewVariadic('[', "{", ExprList{}) // '[' must match "["

Callers

nothing calls this directly

Calls 9

NewBinaryFunction · 0.85
literalOrDieFunction · 0.85
IsLiteralMethod · 0.80
IsFuncallMethod · 0.80
IsBinaryMethod · 0.80
IsUnaryMethod · 0.80
IsVariadicMethod · 0.80
ErrorMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected