@@ -18,29 +18,6 @@ func FuzzExpr(f *testing.F) {
1818 f .Add (s )
1919 }
2020
21- var env = map [string ]any {
22- "ok" : true ,
23- "f64" : .5 ,
24- "f32" : float32 (.5 ),
25- "i" : 1 ,
26- "i64" : int64 (1 ),
27- "i32" : int32 (1 ),
28- "array" : []int {1 , 2 , 3 , 4 , 5 },
29- "list" : []Foo {{"bar" }, {"baz" }},
30- "foo" : Foo {"bar" },
31- "add" : func (a , b int ) int { return a + b },
32- "div" : func (a , b int ) int { return a / b },
33- "half" : func (a float64 ) float64 { return a / 2 },
34- "score" : func (a int , x ... int ) int {
35- s := a
36- for _ , n := range x {
37- s += n
38- }
39- return s
40- },
41- "greet" : func (name string ) string { return "Hello, " + name },
42- }
43-
4421 skip := []* regexp.Regexp {
4522 regexp .MustCompile (`cannot fetch .* from .*` ),
4623 regexp .MustCompile (`cannot get .* from .*` ),
@@ -71,6 +48,8 @@ func FuzzExpr(f *testing.F) {
7148 regexp .MustCompile (`cannot parse .* as .*` ),
7249 }
7350
51+ env := NewEnv ()
52+
7453 f .Fuzz (func (t * testing.T , code string ) {
7554 program , err := expr .Compile (code , expr .Env (env ))
7655 if err != nil {
@@ -89,15 +68,3 @@ func FuzzExpr(f *testing.F) {
8968 }
9069 })
9170}
92-
93- type Foo struct {
94- Bar string
95- }
96-
97- func (f Foo ) String () string {
98- return "foo"
99- }
100-
101- func (f Foo ) Qux (s string ) string {
102- return f .Bar + s
103- }
0 commit comments