aboutsummaryrefslogtreecommitdiff
path: root/src/reflect
diff options
context:
space:
mode:
authorJes Cok <xigua67damn@gmail.com>2024-05-23 23:17:52 +0800
committerGopher Robot <gobot@golang.org>2024-09-24 15:45:23 +0000
commit83fbd0a37bb8c67400e29437db67b6098cf3d5ff (patch)
tree69668707f086e2bb93051d65b320b891c3361d64 /src/reflect
parentbc047b62b2ec0c6eae3437a26410039c82365f60 (diff)
downloadgo-83fbd0a37bb8c67400e29437db67b6098cf3d5ff.tar.xz
reflect: slightly improve iter tests
Change-Id: Ia0e3d668a2435b2ee72e1c641092445902168e4a Reviewed-on: https://go-review.googlesource.com/c/go/+/587875 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
Diffstat (limited to 'src/reflect')
-rw-r--r--src/reflect/iter_test.go13
1 files 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")