funcs_test.go: fixed and extended
This commit is contained in:
parent
389d48b646
commit
d4f63a3837
@ -20,7 +20,7 @@ func TestFuncs(t *testing.T) {
|
|||||||
/* 7 */ {`int(3.9)`, int64(3), nil},
|
/* 7 */ {`int(3.9)`, int64(3), nil},
|
||||||
/* 8 */ {`int("432")`, int64(432), nil},
|
/* 8 */ {`int("432")`, int64(432), nil},
|
||||||
/* 9 */ {`int("1.5")`, nil, errors.New(`strconv.Atoi: parsing "1.5": invalid syntax`)},
|
/* 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 <nil> to int`)},
|
/* 11 */ {`int(nil)`, nil, errors.New(`int() can't convert <nil> to int`)},
|
||||||
/* 12 */ {`two=func(){2}; two()`, int64(2), nil},
|
/* 12 */ {`two=func(){2}; two()`, int64(2), nil},
|
||||||
/* 13 */ {`double=func(x) {2*x}; (double(3))`, int64(6), 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},
|
/* 41 */ {`builtin "string"; endsWithStr("0123456789", "xyz", "789")`, true, nil},
|
||||||
/* 42 */ {`builtin "string"; endsWithStr("0123456789", "xyz", "0125")`, false, 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`)},
|
/* 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},
|
/* 44 */ {`builtin "string"; splitStr("one-two-three", "-", )`, newListA("one", "two", "three"), nil},
|
||||||
/* 45 */ {`["a", "b", "c"]`, newListA("a","b","c"), nil},
|
/* 45 */ {`isInt(2+1)`, true, nil},
|
||||||
/* 46 */ {`["a", "b", "c"]`, newList([]any{"a","b","c"}), 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", ".")
|
t.Setenv("EXPR_PATH", ".")
|
||||||
|
Loading…
Reference in New Issue
Block a user