1
0
mirror of https://github.com/golang/go synced 2024-11-14 13:20:30 -07:00

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 <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
This commit is contained in:
Elias Naur 2024-10-06 18:47:56 +02:00 committed by Gopher Robot
parent 7e2487cf65
commit 604eaa175b

View File

@ -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