MCPcopy
hub / github.com/expr-lang/expr / FuzzExpr

Function FuzzExpr

test/fuzz/fuzz_test.go:16–95  ·  view source on GitHub ↗
(f *testing.F)

Source from the content-addressed store, hash-verified

14var fuzzCorpus string
15
16func FuzzExpr(f *testing.F) {
17 corpus := strings.Split(strings.TrimSpace(fuzzCorpus), "\n")
18 for _, s := range corpus {
19 f.Add(s)
20 }
21
22 skip := []*regexp.Regexp{
23 regexp.MustCompile(`cannot fetch .* from .*`),
24 regexp.MustCompile(`cannot get .* from .*`),
25 regexp.MustCompile(`cannot slice`),
26 regexp.MustCompile(`slice index out of range`),
27 regexp.MustCompile(`error parsing regexp`),
28 regexp.MustCompile(`integer divide by zero`),
29 regexp.MustCompile(`interface conversion`),
30 regexp.MustCompile(`invalid argument`),
31 regexp.MustCompile(`invalid character`),
32 regexp.MustCompile(`invalid operation`),
33 regexp.MustCompile(`invalid duration`),
34 regexp.MustCompile(`time: missing unit in duration`),
35 regexp.MustCompile(`time: unknown unit .* in duration`),
36 regexp.MustCompile(`unknown time zone`),
37 regexp.MustCompile(`invalid location name`),
38 regexp.MustCompile(`json: unsupported value`),
39 regexp.MustCompile(`json: unsupported type`),
40 regexp.MustCompile(`json: cannot unmarshal .* into Go value of type .*`),
41 regexp.MustCompile(`unexpected end of JSON input`),
42 regexp.MustCompile(`memory budget exceeded`),
43 regexp.MustCompile(`using interface \{} as type .*`),
44 regexp.MustCompile(`reflect.Value.MapIndex: value of type .* is not assignable to type .*`),
45 regexp.MustCompile(`reflect: Call using .* as type .*`),
46 regexp.MustCompile(`reflect: cannot use .* as type .* in .*`),
47 regexp.MustCompile(`reflect: Call with too few input arguments`),
48 regexp.MustCompile(`invalid number of arguments`),
49 regexp.MustCompile(`reflect: call of reflect.Value.Call on .* Value`),
50 regexp.MustCompile(`reflect: call of reflect.Value.Index on map Value`),
51 regexp.MustCompile(`reflect: call of reflect.Value.Len on .* Value`),
52 regexp.MustCompile(`reflect: string index out of range`),
53 regexp.MustCompile(`strings: negative Repeat count`),
54 regexp.MustCompile(`strings: illegal bytes to escape`),
55 regexp.MustCompile(`invalid date .*`),
56 regexp.MustCompile(`parsing time .*`),
57 regexp.MustCompile(`cannot parse .* as .*`),
58 regexp.MustCompile(`operator "in" not defined on .*`),
59 regexp.MustCompile(`cannot sum .*`),
60 regexp.MustCompile(`index out of range: .* \(array length is .*\)`),
61 regexp.MustCompile(`reduce of empty array with no initial value`),
62 regexp.MustCompile(`cannot use <nil> as argument \(type .*\) to call .*`),
63 regexp.MustCompile(`illegal base64 data at input byte .*`),
64 regexp.MustCompile(`sort order argument must be a string`),
65 regexp.MustCompile(`sortBy order argument must be a string`),
66 regexp.MustCompile(`invalid order .*, expected asc or desc`),
67 regexp.MustCompile(`unknown order, use asc or desc`),
68 }
69
70 env := NewEnv()
71 fn := Func()
72
73 f.Fuzz(func(t *testing.T, code string) {

Callers

nothing calls this directly

Calls 9

RunMethod · 0.95
CompileFunction · 0.92
EnvStruct · 0.92
NewEnvFunction · 0.85
FuncFunction · 0.85
SplitMethod · 0.80
AddMethod · 0.65
ErrorfMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…