If I build a matcher with gcustom.MakeMatcher, it panics on nil actual value
Context("when the match func accepts a nil-able type", func() {
It("ensure nil matches the type", func() {
var passedIn any
m := gcustom.MakeMatcher(func(a *someType) (bool, error) {
passedIn = a
return true, nil
})
success, err := m.Match(nil)
Ω(success).Should(BeTrue())
Ω(err).ShouldNot(HaveOccurred())
Ω(passedIn).Should(BeNil())
})
})
• [PANICKED] [0.000 seconds]
MakeMatcher validating and wrapping the MatchFunc when the match func accepts a nil-able type [It] ensure nil matches the type
/home/hou/src/gomega/gcustom/make_matcher_test.go:153
[PANICKED] Test Panicked
In [It] at: /usr/local/go/src/runtime/panic.go:260 @ 05/18/23 14:31:58.603
runtime error: invalid memory address or nil pointer dereference
Full Stack Trace
github.com/onsi/gomega/gcustom.MakeMatcher.func1({0xc000013de8, 0x1, 0x1?})
/home/hou/src/gomega/gcustom/make_matcher.go:103 +0x13c
github.com/onsi/gomega/gcustom.CustomGomegaMatcher.Match(...)
/home/hou/src/gomega/gcustom/make_matcher.go:219
github.com/onsi/gomega/gcustom_test.glob..func1.2.12.1()
/home/hou/src/gomega/gcustom/make_matcher_test.go:160 +0x155
If I build a matcher with
gcustom.MakeMatcher
, it panics on nil actual value