]> Cypherpunks.ru repositories - gostls13.git/commitdiff
go/types, types2: add a test case to ConvertibleTo
authorRobert Griesemer <gri@golang.org>
Thu, 14 Oct 2021 19:41:29 +0000 (12:41 -0700)
committerRobert Griesemer <gri@golang.org>
Thu, 14 Oct 2021 21:08:41 +0000 (21:08 +0000)
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 <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
src/cmd/compile/internal/types2/api_test.go
src/go/types/api_test.go

index 4966848ed41ca509bc1a0813ef6a65182a3551f1..ecb5a29830e5d927b23e4c8464d13b45421df729 100644 (file)
@@ -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 {
index 9044449e5c793f448a37912f54f888dabc109204..b331ad929baabaf6fae76ed7cc2f8e2e3177f5c2 100644 (file)
@@ -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 {