changes to adapt errors using typeName() functions
This commit is contained in:
+6
-19
@@ -18,6 +18,8 @@ type inputType struct {
|
||||
}
|
||||
|
||||
func TestGeneralParser(t *testing.T) {
|
||||
section := "Parser"
|
||||
|
||||
inputs := []inputType{
|
||||
/* 1 */ {`1+/*5*/2`, int64(3), nil},
|
||||
/* 2 */ {`3 == 4`, false, nil},
|
||||
@@ -115,8 +117,8 @@ func TestGeneralParser(t *testing.T) {
|
||||
/* 94 */ {`false or true`, true, nil},
|
||||
/* 95 */ {`false or (x==2)`, nil, errors.New(`undefined variable or function "x"`)},
|
||||
/* 96 */ {`a=5; a`, int64(5), nil},
|
||||
/* 97 */ {`2=5`, nil, errors.New(`[1:2] left operand of "=" must be a variable`)},
|
||||
/* 98 */ {`2+a=5`, nil, errors.New(`[1:3] left operand of "=" must be a variable`)},
|
||||
/* 97 */ {`2=5`, nil, errors.New(`[1:2] left operand of "=" must be a variable or a collection's item`)},
|
||||
/* 98 */ {`2+a=5`, nil, errors.New(`[1:3] left operand of "=" must be a variable or a collection's item`)},
|
||||
/* 99 */ {`2+(a=5)`, int64(7), nil},
|
||||
/* 100 */ {`x ?? "default"`, "default", nil},
|
||||
/* 101 */ {`x="hello"; x ?? "default"`, "hello", nil},
|
||||
@@ -145,8 +147,8 @@ func TestGeneralParser(t *testing.T) {
|
||||
}
|
||||
|
||||
// t.Setenv("EXPR_PATH", ".")
|
||||
// parserTestSpec(t, "General", inputs, 102)
|
||||
parserTest(t, "General", inputs)
|
||||
// parserTestSpec(t, section, inputs, 102)
|
||||
parserTest(t, section, inputs)
|
||||
}
|
||||
|
||||
func parserTestSpec(t *testing.T, section string, inputs []inputType, spec ...int) {
|
||||
@@ -214,21 +216,6 @@ func doTest(t *testing.T, section string, input *inputType, count int) (good boo
|
||||
return
|
||||
}
|
||||
|
||||
/*
|
||||
func typeName(v any) (s string) {
|
||||
if v != nil {
|
||||
if typer,ok:=v.(Typer);ok {
|
||||
s = typer.TypeName()
|
||||
}else{
|
||||
s=fmt.Sprintf("%T", v)
|
||||
}
|
||||
} else {
|
||||
s = "nil"
|
||||
}
|
||||
return
|
||||
}
|
||||
*/
|
||||
|
||||
func logTest(t *testing.T, n int, section, source string, wantResult any, wantErr error) {
|
||||
if wantErr == nil {
|
||||
t.Logf("[+]%s nr %3d -- %q --> %v", section, n, source, wantResult)
|
||||
|
||||
Reference in New Issue
Block a user