// Copyright (c) 2024 Celestino Amoroso (celestino.amoroso@gmail.com). // All rights reserved. // t_operator_test.go package expr import ( "testing" ) func TestOperator(t *testing.T) { section := "Operator" inputs := []inputType{ /* 1 */ {`a=1; unset "a"; a`, nil, `undefined variable or function "a"`}, /* 2 */ {`a=1; unset ["a", "b"]`, int64(1), nil}, /* 3 */ {`f=func(){3}; unset "f()"`, int64(1), nil}, /* 4 */ {`a=1; a<<=1+0`, int64(2), nil}, /* 5 */ {`a=2; a>>=1+0`, int64(1), nil}, /* 6 */ {`1<<1`, int64(2), nil}, /* 7 */ {`1>>1`, int64(0), nil}, /* 8 */ {`1|2`, int64(3), nil}, /* 9 */ {`a=1; a|=2`, int64(3), nil}, /* 10 */ {`3&1`, int64(1), nil}, /* 11 */ {`a=3; a&=1`, int64(1), nil}, /* 12 */ {`~1`, int64(-2), nil}, /* 13 */ {`0x10`, int64(16), nil}, /* 14 */ {`0x1X`, nil, `[1:5] two adjacent operators: "1" and "X"`}, /* 15 */ {`0o10`, int64(8), nil}, /* 16 */ {`0b10`, int64(2), nil}, /* 17 */ {`~true`, nil, `[1:2] prefix/postfix operator "~" do not support operand 'true' [bool]`}, } // t.Setenv("EXPR_PATH", ".") // runTestSuiteSpec(t, section, inputs, 4) runTestSuite(t, section, inputs) }