Bitshift
This commit is contained in:
@@ -434,6 +434,10 @@ func evalIntegerInfixExpression(operator string, left, right object.Object) obje
|
||||
return &object.Integer{Value: leftVal ^ rightVal}
|
||||
case "&":
|
||||
return &object.Integer{Value: leftVal & rightVal}
|
||||
case "<<":
|
||||
return &object.Integer{Value: leftVal << uint64(rightVal)}
|
||||
case ">>":
|
||||
return &object.Integer{Value: leftVal >> uint64(rightVal)}
|
||||
case "<":
|
||||
return nativeBoolToBooleanObject(leftVal < rightVal)
|
||||
case "<=":
|
||||
|
||||
@@ -38,6 +38,8 @@ func TestEvalExpressions(t *testing.T) {
|
||||
{"3 & 6", 2},
|
||||
{`" " * 4`, " "},
|
||||
{`4 * " "`, " "},
|
||||
{"1 << 2", 4},
|
||||
{"4 >> 2", 1},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
|
||||
Reference in New Issue
Block a user