Commit 49b7af8a authored by Russ Cox's avatar Russ Cox

[dev.typealias] reflect: add test for type aliases

For #18130.

Change-Id: Idd77cb391178c185227cfd779c70fec16351f825
Reviewed-on: https://go-review.googlesource.com/35733
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: default avatarRobert Griesemer <gri@golang.org>
Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
parent 9bbb07dd
...@@ -5985,6 +5985,11 @@ func TestUnaddressableField(t *testing.T) { ...@@ -5985,6 +5985,11 @@ func TestUnaddressableField(t *testing.T) {
}) })
} }
type Tint int
type Tint2 = Tint
type Talias1 struct { type Talias1 struct {
byte byte
uint8 uint8
...@@ -5993,6 +5998,11 @@ type Talias1 struct { ...@@ -5993,6 +5998,11 @@ type Talias1 struct {
rune rune
} }
type Talias2 struct {
Tint
Tint2
}
func TestAliasNames(t *testing.T) { func TestAliasNames(t *testing.T) {
t1 := Talias1{byte: 1, uint8: 2, int: 3, int32: 4, rune: 5} t1 := Talias1{byte: 1, uint8: 2, int: 3, int32: 4, rune: 5}
out := fmt.Sprintf("%#v", t1) out := fmt.Sprintf("%#v", t1)
...@@ -6000,4 +6010,12 @@ func TestAliasNames(t *testing.T) { ...@@ -6000,4 +6010,12 @@ func TestAliasNames(t *testing.T) {
if out != want { if out != want {
t.Errorf("Talias1 print:\nhave: %s\nwant: %s", out, want) t.Errorf("Talias1 print:\nhave: %s\nwant: %s", out, want)
} }
t2 := Talias2{Tint: 1, Tint2: 2}
out = fmt.Sprintf("%#v", t2)
want = "reflect_test.Talias2{Tint:1, Tint2:2}"
if out != want {
t.Errorf("Talias2 print:\nhave: %s\nwant: %s", out, want)
}
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment