github.com/xyproto/u-root@v6.0.1-0.20200302025726-5528e0c77a3c+incompatible/cmds/core/elvish/eval/vals/testutils_test.go (about) 1 package vals 2 3 import "github.com/u-root/u-root/cmds/core/elvish/tt" 4 5 var Args = tt.Args 6 7 // anyType matches anything. 8 type anyType struct{} 9 10 var any = anyType{} 11 12 func (anyType) Match(tt.RetValue) bool { return true } 13 14 // anyErrorType matches any value that satisfies the error interface. 15 type anyErrorType struct{} 16 17 var anyError = anyErrorType{} 18 19 func (e anyErrorType) Match(a tt.RetValue) bool { 20 _, ok := a.(error) 21 return ok 22 } 23 24 // equalMatcher matches the return value using Equal. 25 type equalMatcher struct { 26 r interface{} 27 } 28 29 func eq(r interface{}) tt.Matcher { return equalMatcher{r} } 30 31 func (em equalMatcher) Match(a tt.RetValue) bool { return Equal(em.r, a) }