Skip to content

Commit 32bcae1

Browse files
committed
Update fuzz_test.go
1 parent 3dd9300 commit 32bcae1

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

fuzz_test.go

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ func FuzzExpr(f *testing.F) {
1616
"m": map[string]interface{}{"a": 1, "b": 2, "m": map[string]int{"a": 1}},
1717
"s": "abc",
1818
"add": func(a, b int) int { return a + b },
19+
"foo": Foo{A: 1, B: 2, Bar: Bar{A: 1, B: 2}},
1920
}
2021

2122
head := expr.Function(
@@ -97,13 +98,16 @@ func FuzzExpr(f *testing.F) {
9798
`type({a: 1, b: 2})`,
9899
`type(head)`,
99100
`keys(m)`,
101+
`values(m)`,
102+
`foo.bar.a`,
103+
`foo.bar.b`,
100104
}
101105

102106
for _, s := range corpus {
103107
f.Add(s)
104108
}
105109

106-
okCases := []*regexp.Regexp{
110+
skip := []*regexp.Regexp{
107111
regexp.MustCompile(`cannot fetch .* from .*`),
108112
regexp.MustCompile(`cannot get .* from .*`),
109113
regexp.MustCompile(`cannot slice`),
@@ -139,8 +143,8 @@ func FuzzExpr(f *testing.F) {
139143

140144
_, err = expr.Run(program, env)
141145
if err != nil {
142-
for _, okCase := range okCases {
143-
if okCase.MatchString(err.Error()) {
146+
for _, r := range skip {
147+
if r.MatchString(err.Error()) {
144148
t.Skipf("skip error: %s", err)
145149
return
146150
}
@@ -149,3 +153,14 @@ func FuzzExpr(f *testing.F) {
149153
}
150154
})
151155
}
156+
157+
type Foo struct {
158+
A int `expr:"a"`
159+
B int `expr:"b"`
160+
Bar Bar `expr:"bar"`
161+
}
162+
163+
type Bar struct {
164+
A int `expr:"a"`
165+
B int `expr:"b"`
166+
}

0 commit comments

Comments
 (0)