all test file on builtin functions have been renamed from t_func-*_test.go to t_builtin-*_test.go
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
// Copyright (c) 2024 Celestino Amoroso (celestino.amoroso@gmail.com).
|
||||
// All rights reserved.
|
||||
|
||||
// t_func-string_test.go
|
||||
package expr
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestFuncString(t *testing.T) {
|
||||
section := "Func-String"
|
||||
|
||||
inputs := []inputType{
|
||||
/* 1 */ {`builtin "string"; joinStr("-", "one", "two", "three")`, "one-two-three", nil},
|
||||
/* 2 */ {`builtin "string"; joinStr("-", ["one", "two", "three"])`, "one-two-three", nil},
|
||||
/* 3 */ {`builtin "string"; ls= ["one", "two", "three"]; joinStr("-", ls)`, "one-two-three", nil},
|
||||
/* 4 */ {`builtin "string"; ls= ["one", "two", "three"]; joinStr(1, ls)`, nil, errors.New(`joinStr() the "separator" parameter must be a string, got a integer (1)`)},
|
||||
/* 5 */ {`builtin "string"; ls= ["one", 2, "three"]; joinStr("-", ls)`, nil, errors.New(`joinStr() expected string, got integer (2)`)},
|
||||
/* 6 */ {`builtin "string"; "<"+trimStr(" bye bye ")+">"`, "<bye bye>", nil},
|
||||
/* 7 */ {`builtin "string"; subStr("0123456789", 1,2)`, "12", nil},
|
||||
/* 8 */ {`builtin "string"; subStr("0123456789", -3,2)`, "78", nil},
|
||||
/* 9 */ {`builtin "string"; subStr("0123456789", -3)`, "789", nil},
|
||||
/* 10 */ {`builtin "string"; subStr("0123456789")`, "0123456789", nil},
|
||||
/* 11 */ {`builtin "string"; startsWithStr("0123456789", "xyz", "012")`, true, nil},
|
||||
/* 12 */ {`builtin "string"; startsWithStr("0123456789", "xyz", "0125")`, false, nil},
|
||||
/* 13 */ {`builtin "string"; startsWithStr("0123456789")`, nil, errors.New(`startsWithStr(): too few params -- expected 2 or more, got 1`)},
|
||||
/* 14 */ {`builtin "string"; endsWithStr("0123456789", "xyz", "789")`, true, nil},
|
||||
/* 15 */ {`builtin "string"; endsWithStr("0123456789", "xyz", "0125")`, false, nil},
|
||||
/* 16 */ {`builtin "string"; endsWithStr("0123456789")`, nil, errors.New(`endsWithStr(): too few params -- expected 2 or more, got 1`)},
|
||||
/* 17 */ {`builtin "string"; splitStr("one-two-three", "-")`, newListA("one", "two", "three"), nil},
|
||||
/* 18 */ {`builtin "string"; joinStr("-", [1, "two", "three"])`, nil, errors.New(`joinStr() expected string, got integer (1)`)},
|
||||
/* 19 */ {`builtin "string"; joinStr()`, nil, errors.New(`joinStr(): too few params -- expected 1 or more, got 0`)},
|
||||
|
||||
/* 69 */ /*{`builtin "string"; $$global`, `vars: {
|
||||
}
|
||||
funcs: {
|
||||
add(any=0 ...) -> number,
|
||||
dec(any) -> decimal,
|
||||
endsWithStr(source, suffix) -> boolean,
|
||||
fract(any, denominator=1) -> fraction,
|
||||
import( ...) -> any,
|
||||
importAll( ...) -> any,
|
||||
int(any) -> integer,
|
||||
isBool(any) -> boolean,
|
||||
isDec(any) -> boolean,
|
||||
isDict(any) -> boolean,
|
||||
isFloat(any) -> boolean,
|
||||
isFract(any) -> boolean,
|
||||
isInt(any) -> boolean,
|
||||
isList(any) -> boolean,
|
||||
isNil(any) -> boolean,
|
||||
isString(any) -> boolean,
|
||||
joinStr(separator, item="" ...) -> string,
|
||||
mul(any=1 ...) -> number,
|
||||
splitStr(source, separator="", count=-1) -> list of string,
|
||||
startsWithStr(source, prefix) -> boolean,
|
||||
subStr(source, start=0, count=-1) -> string,
|
||||
trimStr(source) -> string
|
||||
}
|
||||
`, nil},*/
|
||||
}
|
||||
|
||||
//t.Setenv("EXPR_PATH", ".")
|
||||
|
||||
// parserTestSpec(t, section, inputs, 19)
|
||||
parserTest(t, section, inputs)
|
||||
}
|
||||
Reference in New Issue
Block a user