diff --git a/internal/async_assertion.go b/internal/async_assertion.go index 6640ff15f..126bbcb3f 100644 --- a/internal/async_assertion.go +++ b/internal/async_assertion.go @@ -40,7 +40,7 @@ func NewAsyncAssertion(asyncType AsyncAssertionType, actualInput interface{}, g } switch actualType := reflect.TypeOf(actualInput); { - case actualType.Kind() != reflect.Func: + case actualInput == nil || actualType.Kind() != reflect.Func: out.actualValue = actualInput case actualType.NumIn() == 0 && actualType.NumOut() > 0: out.actualIsFunc = true diff --git a/internal/async_assertion_test.go b/internal/async_assertion_test.go index 3c67520b0..1bedfdf58 100644 --- a/internal/async_assertion_test.go +++ b/internal/async_assertion_test.go @@ -742,4 +742,22 @@ var _ = Describe("Asynchronous Assertions", func() { }) + Context("eventual nil-ism", func() { // issue #555 + + It("doesn't panic on nil actual", func() { + ig := NewInstrumentedGomega() + Expect(func() { + ig.G.Eventually(nil).Should(BeNil()) + }).NotTo(Panic()) + }) + + It("doesn't panic on function returning nil error", func() { + ig := NewInstrumentedGomega() + Expect(func() { + ig.G.Eventually(func() error { return nil }).Should(BeNil()) + }).NotTo(Panic()) + }) + + }) + })