30 lines
1001 B
Go
30 lines
1001 B
Go
|
// Copyright (c) 2024 Celestino Amoroso (celestino.amoroso@gmail.com).
|
||
|
// All rights reserved.
|
||
|
|
||
|
// t_func-math-arith_test.go
|
||
|
package expr
|
||
|
|
||
|
import (
|
||
|
"errors"
|
||
|
"testing"
|
||
|
)
|
||
|
|
||
|
func TestFuncMathArith(t *testing.T) {
|
||
|
section := "Func-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, errors.New(`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},
|
||
|
}
|
||
|
|
||
|
// t.Setenv("EXPR_PATH", ".")
|
||
|
|
||
|
// parserTestSpec(t, section, inputs, 69)
|
||
|
parserTest(t, section, inputs)
|
||
|
}
|