From 604eaa175bfaadfb868d6add76325020b6e13048 Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Sun, 6 Oct 2024 18:47:56 +0200 Subject: [PATCH] iter: fix spurious TestPullDoubleYield[2] successes The two tests confused a nil pointer panic with the panic from a double call to yield. Change-Id: I0040e60cf4b702a92825d308db1201a85f164009 Reviewed-on: https://go-review.googlesource.com/c/go/+/617917 Reviewed-by: Ian Lance Taylor LUCI-TryBot-Result: Go LUCI Auto-Submit: Ian Lance Taylor Reviewed-by: Cherry Mui --- src/iter/pull_test.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/iter/pull_test.go b/src/iter/pull_test.go index 449edee031..e9e3bdadca 100644 --- a/src/iter/pull_test.go +++ b/src/iter/pull_test.go @@ -193,7 +193,11 @@ func doDoubleNext2() Seq2[int, int] { } func TestPullDoubleYield(t *testing.T) { - _, stop := Pull(storeYield()) + next, stop := Pull(storeYield()) + next() + if yieldSlot == nil { + t.Fatal("yield failed") + } defer func() { if recover() != nil { yieldSlot = nil @@ -218,7 +222,11 @@ func storeYield() Seq[int] { var yieldSlot func(int) bool func TestPullDoubleYield2(t *testing.T) { - _, stop := Pull2(storeYield2()) + next, stop := Pull2(storeYield2()) + next() + if yieldSlot2 == nil { + t.Fatal("yield failed") + } defer func() { if recover() != nil { yieldSlot2 = nil -- 2.48.1