From d4f63a3837226a13766e15f3c83fdb13f3b04924 Mon Sep 17 00:00:00 2001 From: Celestino Amoroso Date: Fri, 10 May 2024 04:44:08 +0200 Subject: [PATCH] funcs_test.go: fixed and extended --- funcs_test.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/funcs_test.go b/funcs_test.go index 1103378..bd3b835 100644 --- a/funcs_test.go +++ b/funcs_test.go @@ -20,7 +20,7 @@ func TestFuncs(t *testing.T) { /* 7 */ {`int(3.9)`, int64(3), nil}, /* 8 */ {`int("432")`, int64(432), nil}, /* 9 */ {`int("1.5")`, nil, errors.New(`strconv.Atoi: parsing "1.5": invalid syntax`)}, - /* 10 */ {`int("432", 4)`, nil, errors.New(`int() requires exactly one param`)}, + /* 10 */ {`int("432", 4)`, nil, errors.New(`too much params -- expected 1, got 2`)}, /* 11 */ {`int(nil)`, nil, errors.New(`int() can't convert to int`)}, /* 12 */ {`two=func(){2}; two()`, int64(2), nil}, /* 13 */ {`double=func(x) {2*x}; (double(3))`, int64(6), nil}, @@ -54,9 +54,15 @@ func TestFuncs(t *testing.T) { /* 41 */ {`builtin "string"; endsWithStr("0123456789", "xyz", "789")`, true, nil}, /* 42 */ {`builtin "string"; endsWithStr("0123456789", "xyz", "0125")`, false, nil}, /* 43 */ {`builtin "string"; endsWithStr("0123456789")`, nil, errors.New(`too few params -- expected 2 or more, got 1`)}, - /* 44 */ {`builtin "string"; splitStr("one-two-three", "-", )`, newListA("one","two","three"), nil}, - /* 45 */ {`["a", "b", "c"]`, newListA("a","b","c"), nil}, - /* 46 */ {`["a", "b", "c"]`, newList([]any{"a","b","c"}), nil}, + /* 44 */ {`builtin "string"; splitStr("one-two-three", "-", )`, newListA("one", "two", "three"), nil}, + /* 45 */ {`isInt(2+1)`, true, nil}, + /* 46 */ {`isInt(3.1)`, false, nil}, + /* 46 */ {`isFloat(3.1)`, true, nil}, + /* 47 */ {`isString("3.1")`, true, nil}, + /* 48 */ {`isString("3" + 1)`, true, nil}, + /* 49 */ {`isList(["3", 1])`, true, nil}, + /* 50 */ {`isDict({"a":"3", "b":1})`, true, nil}, + /* 51 */ {`isFract(3|1)`, true, nil}, } t.Setenv("EXPR_PATH", ".")