mirror of
https://github.com/hanzoai/expr.git
synced 2026-09-24 16:58:58 +00:00
Update fuzz tests
This commit is contained in:
+1
-1
@@ -217,7 +217,7 @@ func (v *checker) IdentifierNode(node *ast.IdentifierNode) Nature {
|
||||
return unknown
|
||||
}
|
||||
|
||||
return v.ident(node, node.Value, v.config.Env.Strict, true)
|
||||
return v.ident(node, node.Value, v.config.Strict, true)
|
||||
}
|
||||
|
||||
// ident method returns type of environment variable, builtin or function.
|
||||
|
||||
+1
-1
@@ -62,9 +62,9 @@ func New(env any) *Config {
|
||||
}
|
||||
|
||||
func (c *Config) WithEnv(env any) {
|
||||
c.Strict = true
|
||||
c.EnvObject = env
|
||||
c.Env = Env(env)
|
||||
c.Strict = c.Env.Strict
|
||||
}
|
||||
|
||||
func (c *Config) ConstExpr(name string) {
|
||||
|
||||
@@ -36,6 +36,7 @@ func Env(env any) Nature {
|
||||
n := Nature{
|
||||
Type: v.Type(),
|
||||
Fields: make(map[string]Nature, v.Len()),
|
||||
Strict: true,
|
||||
}
|
||||
|
||||
for _, key := range v.MapKeys() {
|
||||
|
||||
@@ -2716,3 +2716,11 @@ func TestIssue758_filter_map_index(t *testing.T) {
|
||||
|
||||
require.Equal(t, expected, result)
|
||||
}
|
||||
|
||||
func TestExpr_wierd_cases(t *testing.T) {
|
||||
env := map[string]any{}
|
||||
|
||||
_, err := expr.Compile(`A(A)`, expr.Env(env))
|
||||
require.Error(t, err)
|
||||
require.Contains(t, err.Error(), "unknown name A")
|
||||
}
|
||||
|
||||
+13254
-10036
File diff suppressed because it is too large
Load Diff
@@ -51,6 +51,9 @@ func FuzzExpr(f *testing.F) {
|
||||
regexp.MustCompile(`cannot parse .* as .*`),
|
||||
regexp.MustCompile(`operator "in" not defined on .*`),
|
||||
regexp.MustCompile(`cannot sum .*`),
|
||||
regexp.MustCompile(`index out of range: .* \(array length is .*\)`),
|
||||
regexp.MustCompile(`cannot use <nil> as argument \(type .*\) to call .*`),
|
||||
regexp.MustCompile(`illegal base64 data at input byte .*`),
|
||||
}
|
||||
|
||||
env := NewEnv()
|
||||
|
||||
Reference in New Issue
Block a user