34 lines
1.3 KiB
Go
34 lines
1.3 KiB
Go
// Copyright (c) 2024 Celestino Amoroso (celestino.amoroso@gmail.com).
|
|
// All rights reserved.
|
|
|
|
// t_builtin-math-arith_test.go
|
|
package expr
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestFuncMathArith(t *testing.T) {
|
|
section := "Builtin-Math-Arith"
|
|
inputs := []inputType{
|
|
/* 1 */ {`builtin "math.arith"; add(1,2)`, int64(3), nil},
|
|
/* 2 */ {`builtin "math.arith"; add(1,2,3)`, int64(6), nil},
|
|
/* 3 */ {`builtin "math.arith"; mulX(1,2,3)`, nil, `unknown function mulX()`},
|
|
/* 4 */ {`builtin "math.arith"; add(1+4,3+2,5*(3-2))`, int64(15), nil},
|
|
/* 5 */ {`builtin "math.arith"; add(add(1+4),3+2,5*(3-2))`, int64(15), nil},
|
|
/* 6 */ {`builtin "math.arith"; add(add(1,4),/*3+2,*/5*(3-2))`, int64(10), nil},
|
|
/* 7 */ {`builtin "math.arith"; a=5; b=2; add(a, b*3)`, int64(11), nil},
|
|
/* 8 */ {`builtin "math.arith"; var2="abc"; add(1,2) but var2`, "abc", nil},
|
|
/* 9 */ {`builtin "math.arith"; add()`, int64(0), nil},
|
|
/* 10 */ {`builtin "math.arith"; mul()`, int64(1), nil},
|
|
/* 11 */ {`builtin "math.arith"; add([1,2,3])`, int64(6), nil},
|
|
/* 12 */ {`builtin "math.arith"; mul([2,2,3])`, int64(12), nil},
|
|
/* 13 */ {`builtin "math.arith"; mul(2,2,3)`, int64(12), nil},
|
|
}
|
|
|
|
// t.Setenv("EXPR_PATH", ".")
|
|
|
|
//runTestSuiteSpec(t, section, inputs, 10)
|
|
runTestSuite(t, section, inputs)
|
|
}
|