mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-09 21:43:40 +00:00
reflect: add Type.Elem() and Type.Key() for Maps
This commit is contained in:
@@ -30,3 +30,18 @@ func TestIndirectPointers(t *testing.T) {
|
||||
t.Errorf("bad indirect array index via reflect")
|
||||
}
|
||||
}
|
||||
|
||||
func TestMap(t *testing.T) {
|
||||
|
||||
m := make(map[string]int)
|
||||
|
||||
mtyp := TypeOf(m)
|
||||
|
||||
if got, want := mtyp.Key().Kind().String(), "string"; got != want {
|
||||
t.Errorf("m.Type().Key().String()=%q, want %q", got, want)
|
||||
}
|
||||
|
||||
if got, want := mtyp.Elem().Kind().String(), "int"; got != want {
|
||||
t.Errorf("m.Elem().String()=%q, want %q", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user