Skip to content

Commit 83fbd0a

Browse files
callthingsoffgopherbot
authored andcommitted
reflect: slightly improve iter tests
Change-Id: Ia0e3d668a2435b2ee72e1c641092445902168e4a Reviewed-on: https://go-review.googlesource.com/c/go/+/587875 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> Auto-Submit: Ian Lance Taylor <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent bc047b6 commit 83fbd0a

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/reflect/iter_test.go

+5-8
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,10 @@ func TestValueSeq(t *testing.T) {
114114
}},
115115
{"string", ValueOf("12语言"), func(t *testing.T, s iter.Seq[Value]) {
116116
i := int64(0)
117-
indexs := []int64{0, 1, 2, 5}
117+
indexes := []int64{0, 1, 2, 5}
118118
for v := range s {
119-
if v.Int() != indexs[i] {
120-
t.Fatalf("got %d, want %d", v.Int(), indexs[i])
119+
if v.Int() != indexes[i] {
120+
t.Fatalf("got %d, want %d", v.Int(), indexes[i])
121121
}
122122
i++
123123
}
@@ -126,14 +126,12 @@ func TestValueSeq(t *testing.T) {
126126
}
127127
}},
128128
{"map[string]int", ValueOf(m), func(t *testing.T, s iter.Seq[Value]) {
129-
i := int64(0)
130129
copy := maps.Clone(m)
131130
for v := range s {
132131
if _, ok := copy[v.String()]; !ok {
133132
t.Fatalf("unexpected %v", v.Interface())
134133
}
135134
delete(copy, v.String())
136-
i++
137135
}
138136
if len(copy) != 0 {
139137
t.Fatalf("should loop four times")
@@ -240,11 +238,10 @@ func TestValueSeq2(t *testing.T) {
240238
}
241239
}},
242240
{"string", ValueOf("12语言"), func(t *testing.T, s iter.Seq2[Value, Value]) {
243-
i := int64(0)
244-
str := "12语言"
245241
next, stop := iter.Pull2(s)
246242
defer stop()
247-
for j, s := range str {
243+
i := int64(0)
244+
for j, s := range "12语言" {
248245
v1, v2, ok := next()
249246
if !ok {
250247
t.Fatalf("should loop four times")

0 commit comments

Comments
 (0)