Bitshift
Some checks failed
Test / build (push) Waiting to run
Build / build (push) Has been cancelled

This commit is contained in:
Chuck Smith
2024-03-24 16:22:11 -04:00
parent a08fc1520c
commit 3c66b980e7
11 changed files with 76 additions and 12 deletions

View File

@@ -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 "<=":

View File

@@ -38,6 +38,8 @@ func TestEvalExpressions(t *testing.T) {
{"3 & 6", 2},
{`" " * 4`, " "},
{`4 * " "`, " "},
{"1 << 2", 4},
{"4 >> 2", 1},
}
for _, tt := range tests {