Skip to content

Commit

Permalink
reflect: slightly improve iter tests
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
callthingsoff authored and gopherbot committed Sep 24, 2024
1 parent bc047b6 commit 83fbd0a
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/reflect/iter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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++
}
Expand All @@ -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")
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 83fbd0a

Please sign in to comment.