From 83fbd0a37bb8c67400e29437db67b6098cf3d5ff Mon Sep 17 00:00:00 2001 From: Jes Cok Date: Thu, 23 May 2024 23:17:52 +0800 Subject: [PATCH] reflect: slightly improve iter tests Change-Id: Ia0e3d668a2435b2ee72e1c641092445902168e4a Reviewed-on: https://go-review.googlesource.com/c/go/+/587875 LUCI-TryBot-Result: Go LUCI Reviewed-by: Dmitri Shuralyov Auto-Submit: Ian Lance Taylor Reviewed-by: Ian Lance Taylor --- src/reflect/iter_test.go | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/reflect/iter_test.go b/src/reflect/iter_test.go index 9b78fcf724..00ae521af9 100644 --- a/src/reflect/iter_test.go +++ b/src/reflect/iter_test.go @@ -114,10 +114,10 @@ func TestValueSeq(t *testing.T) { }}, {"string", ValueOf("12语言"), func(t *testing.T, s iter.Seq[Value]) { i := int64(0) - indexs := []int64{0, 1, 2, 5} + indexes := []int64{0, 1, 2, 5} for v := range s { - if v.Int() != indexs[i] { - t.Fatalf("got %d, want %d", v.Int(), indexs[i]) + if v.Int() != indexes[i] { + t.Fatalf("got %d, want %d", v.Int(), indexes[i]) } i++ } @@ -126,14 +126,12 @@ func TestValueSeq(t *testing.T) { } }}, {"map[string]int", ValueOf(m), func(t *testing.T, s iter.Seq[Value]) { - i := int64(0) copy := maps.Clone(m) for v := range s { if _, ok := copy[v.String()]; !ok { t.Fatalf("unexpected %v", v.Interface()) } delete(copy, v.String()) - i++ } if len(copy) != 0 { t.Fatalf("should loop four times") @@ -240,11 +238,10 @@ func TestValueSeq2(t *testing.T) { } }}, {"string", ValueOf("12语言"), func(t *testing.T, s iter.Seq2[Value, Value]) { - i := int64(0) - str := "12语言" next, stop := iter.Pull2(s) defer stop() - for j, s := range str { + i := int64(0) + for j, s := range "12语言" { v1, v2, ok := next() if !ok { t.Fatalf("should loop four times") -- 2.48.1