]> Cypherpunks repositories - gostls13.git/commitdiff
iter: fix spurious TestPullDoubleYield[2] successes
authorElias Naur <mail@eliasnaur.com>
Sun, 6 Oct 2024 16:47:56 +0000 (18:47 +0200)
committerGopher Robot <gobot@golang.org>
Mon, 7 Oct 2024 19:12:35 +0000 (19:12 +0000)
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>
src/iter/pull_test.go

index 449edee031dcd7c43354faf92892cd7ea53bdb6e..e9e3bdadca099354f57bb17a3110b4431dd3949a 100644 (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