MCPcopy
hub / github.com/gopherjs/gopherjs / TestMapIterSet

Function TestMapIterSet

compiler/natives/src/reflect/reflect_test.go:186–215  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

184}
185
186func TestMapIterSet(t *testing.T) {
187 m := make(map[string]any, len(valueTests))
188 for _, tt := range valueTests {
189 m[tt.s] = tt.i
190 }
191 v := ValueOf(m)
192
193 k := New(v.Type().Key()).Elem()
194 e := New(v.Type().Elem()).Elem()
195
196 iter := v.MapRange()
197 for iter.Next() {
198 k.SetIterKey(iter)
199 e.SetIterValue(iter)
200 want := m[k.String()]
201 got := e.Interface()
202 if got != want {
203 t.Errorf("%q: want (%T) %v, got (%T) %v", k.String(), want, want, got, got)
204 }
205 if setkey, key := valueToString(k), valueToString(iter.Key()); setkey != key {
206 t.Errorf("MapIter.Key() = %q, MapIter.SetKey() = %q", key, setkey)
207 }
208 if setval, val := valueToString(e), valueToString(iter.Value()); setval != val {
209 t.Errorf("MapIter.Value() = %q, MapIter.SetValue() = %q", val, setval)
210 }
211 }
212
213 // Upstream test also tests allocations made by the iterator. GopherJS doesn't
214 // support runtime.ReadMemStats(), so we leave that part out.
215}
216
217type inner struct {
218 x int

Callers

nothing calls this directly

Calls 8

NextMethod · 0.80
ValueMethod · 0.80
ValueOfFunction · 0.70
NewFunction · 0.70
TypeMethod · 0.65
StringMethod · 0.65
ElemMethod · 0.45
InterfaceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…