mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
[dev.typeparams] all: merge master (798ec73) into dev.typeparams
Merge List: + 2021-07-22798ec73519runtime: don't clear timerModifiedEarliest if adjustTimers is 0 + 2021-07-22fdb45acd1fruntime: move mem profile sampling into m-acquired section + 2021-07-213e48c0381freflect: add missing copyright header + 2021-07-2148c88f1b1breflect: add Value.CanConvert + 2021-07-209e26569293cmd/go: don't add C compiler ID to hash for standard library + 2021-07-20d568e6e075runtime/debug: skip TestPanicOnFault on netbsd/arm Change-Id: I87e1cd4614bb3b00807f18dfdd02664dcaecaebd
This commit is contained in:
commit
a27e325c59
13 changed files with 138 additions and 19 deletions
|
|
@ -4305,6 +4305,9 @@ func TestConvert(t *testing.T) {
|
|||
|
||||
// vout1 represents the in value converted to the in type.
|
||||
v1 := tt.in
|
||||
if !v1.CanConvert(t1) {
|
||||
t.Errorf("ValueOf(%T(%[1]v)).CanConvert(%s) = false, want true", tt.in.Interface(), t1)
|
||||
}
|
||||
vout1 := v1.Convert(t1)
|
||||
out1 := vout1.Interface()
|
||||
if vout1.Type() != tt.in.Type() || !DeepEqual(out1, tt.in.Interface()) {
|
||||
|
|
@ -4312,6 +4315,9 @@ func TestConvert(t *testing.T) {
|
|||
}
|
||||
|
||||
// vout2 represents the in value converted to the out type.
|
||||
if !v1.CanConvert(t2) {
|
||||
t.Errorf("ValueOf(%T(%[1]v)).CanConvert(%s) = false, want true", tt.in.Interface(), t2)
|
||||
}
|
||||
vout2 := v1.Convert(t2)
|
||||
out2 := vout2.Interface()
|
||||
if vout2.Type() != tt.out.Type() || !DeepEqual(out2, tt.out.Interface()) {
|
||||
|
|
@ -4372,6 +4378,9 @@ func TestConvertPanic(t *testing.T) {
|
|||
if !v.Type().ConvertibleTo(pt) {
|
||||
t.Errorf("[]byte should be convertible to *[8]byte")
|
||||
}
|
||||
if v.CanConvert(pt) {
|
||||
t.Errorf("slice with length 4 should not be convertible to *[8]byte")
|
||||
}
|
||||
shouldPanic("reflect: cannot convert slice with length 4 to pointer to array with length 8", func() {
|
||||
_ = v.Convert(pt)
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue