mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-17 11:13:27 +00:00
reflect: improve Value.String()
This commit is contained in:
committed by
Damian Gryski
parent
90af41d089
commit
2a821d2a66
@@ -381,7 +381,7 @@ func (v Value) String() string {
|
|||||||
return *(*string)(v.value)
|
return *(*string)(v.value)
|
||||||
default:
|
default:
|
||||||
// Special case because of the special treatment of .String() in Go.
|
// Special case because of the special treatment of .String() in Go.
|
||||||
return "<T>"
|
return "<" + v.typecode.String() + " Value>"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -221,7 +221,9 @@ func TestNamedTypes(t *testing.T) {
|
|||||||
t.Errorf("TypeOf.Name()=%v, want %v", got, want)
|
t.Errorf("TypeOf.Name()=%v, want %v", got, want)
|
||||||
}
|
}
|
||||||
|
|
||||||
if got, want := TypeOf(map[[4]uint16]string{}).String(), "map[[4]uint16]string"; got != want {
|
m := make(map[[4]uint16]string)
|
||||||
|
|
||||||
|
if got, want := TypeOf(m).String(), "map[[4]uint16]string"; got != want {
|
||||||
t.Errorf("Type.String()=%v, want %v", got, want)
|
t.Errorf("Type.String()=%v, want %v", got, want)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -238,6 +240,9 @@ func TestNamedTypes(t *testing.T) {
|
|||||||
t.Errorf("Type.String()=%v, want %v", got, want)
|
t.Errorf("Type.String()=%v, want %v", got, want)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if got, want := ValueOf(m).String(), "<map[[4]uint16]string Value>"; got != want {
|
||||||
|
t.Errorf("Value.String()=%v, want %v", got, want)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func equal[T comparable](a, b []T) bool {
|
func equal[T comparable](a, b []T) bool {
|
||||||
|
|||||||
Reference in New Issue
Block a user