Expr's functions now support parameters with default value

This commit is contained in:
2024-06-01 19:56:40 +02:00
parent f66cd1fdb1
commit 9bba40f155
12 changed files with 180 additions and 247 deletions
+5 -2
View File
@@ -26,11 +26,14 @@ func TestFuncs(t *testing.T) {
/* 12 */ {`f=func(@y){g=func(){@x=5}; g(); @z=x; @x=@y+@z}; f(2); y+x`, int64(9), nil},
/* 13 */ {`two=func(){2}; four=func(f){f()+f()}; four(two)`, int64(4), nil},
/* 14 */ {`two=func(){2}; two(123)`, nil, errors.New(`two(): too much params -- expected 0, got 1`)},
/* 15 */ {`f=func(x,n=2){x+n}; f(3)`, int64(5), nil},
/* 16 */ {`f=func(x,n=2,y){x+n}`, nil, errors.New(`[1:16] can't mix default and non-default parameters`)},
/* 17 */ {`f=func(x,n){1}; f(3,4,)`, nil, errors.New(`[1:24] expected "function-param-value", got ")"`)},
}
t.Setenv("EXPR_PATH", ".")
// t.Setenv("EXPR_PATH", ".")
// parserTestSpec(t, section, inputs, 69)
// parserTestSpec(t, section, inputs, 17)
parserTest(t, section, inputs)
}