From: Robert Griesemer Date: Thu, 14 Oct 2021 19:41:29 +0000 (-0700) Subject: go/types, types2: add a test case to ConvertibleTo X-Git-Tag: go1.18beta1~895 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=0400d536e4f349c8f30777c975af78b6a19e73b4;p=gostls13.git go/types, types2: add a test case to ConvertibleTo string(int) conversions are somewhat special and deserve an entry. Change-Id: Ia68d047cfdb2f98e837bf663659f7f46404b16ac Reviewed-on: https://go-review.googlesource.com/c/go/+/355989 Trust: Robert Griesemer Reviewed-by: Robert Findley --- diff --git a/src/cmd/compile/internal/types2/api_test.go b/src/cmd/compile/internal/types2/api_test.go index 4966848ed4..ecb5a29830 100644 --- a/src/cmd/compile/internal/types2/api_test.go +++ b/src/cmd/compile/internal/types2/api_test.go @@ -1655,6 +1655,7 @@ func TestConvertibleTo(t *testing.T) { }{ {Typ[Int], Typ[Int], true}, {Typ[Int], Typ[Float32], true}, + {Typ[Int], Typ[String], true}, {newDefined(Typ[Int]), Typ[Int], true}, {newDefined(new(Struct)), new(Struct), true}, {newDefined(Typ[Int]), new(Struct), false}, @@ -1662,8 +1663,7 @@ func TestConvertibleTo(t *testing.T) { {NewSlice(Typ[Int]), NewPointer(NewArray(Typ[Int], 10)), true}, {NewSlice(Typ[Int]), NewArray(Typ[Int], 10), false}, {NewSlice(Typ[Int]), NewPointer(NewArray(Typ[Uint], 10)), false}, - // Untyped string values are not permitted by the spec, so the below - // behavior is undefined. + // Untyped string values are not permitted by the spec, so the behavior below is undefined. {Typ[UntypedString], Typ[String], true}, } { if got := ConvertibleTo(test.v, test.t); got != test.want { diff --git a/src/go/types/api_test.go b/src/go/types/api_test.go index 9044449e5c..b331ad929b 100644 --- a/src/go/types/api_test.go +++ b/src/go/types/api_test.go @@ -1631,6 +1631,7 @@ func TestConvertibleTo(t *testing.T) { }{ {Typ[Int], Typ[Int], true}, {Typ[Int], Typ[Float32], true}, + {Typ[Int], Typ[String], true}, {newDefined(Typ[Int]), Typ[Int], true}, {newDefined(new(Struct)), new(Struct), true}, {newDefined(Typ[Int]), new(Struct), false}, @@ -1638,8 +1639,7 @@ func TestConvertibleTo(t *testing.T) { {NewSlice(Typ[Int]), NewPointer(NewArray(Typ[Int], 10)), true}, {NewSlice(Typ[Int]), NewArray(Typ[Int], 10), false}, {NewSlice(Typ[Int]), NewPointer(NewArray(Typ[Uint], 10)), false}, - // Untyped string values are not permitted by the spec, so the below - // behavior is undefined. + // Untyped string values are not permitted by the spec, so the behavior below is undefined. {Typ[UntypedString], Typ[String], true}, } { if got := ConvertibleTo(test.v, test.t); got != test.want {