diff options
author | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
---|---|---|
committer | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
commit | 554fd8c5195424bdbcabf5de30fdc183aba391bd (patch) | |
tree | 976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/go.test/test/interface/embed.go | |
download | cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2 cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz |
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig;
imported gcc-4.6.4 source tree from verified upstream tarball.
downloading a git-generated archive based on the 'upstream' tag
should provide you with a source tree that is binary identical
to the one extracted from the above tarball.
if you have obtained the source via the command 'git clone',
however, do note that line-endings of files in your working
directory might differ from line-endings of the respective
files in the upstream repository.
Diffstat (limited to 'gcc/testsuite/go.test/test/interface/embed.go')
-rw-r--r-- | gcc/testsuite/go.test/test/interface/embed.go | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/gcc/testsuite/go.test/test/interface/embed.go b/gcc/testsuite/go.test/test/interface/embed.go new file mode 100644 index 000000000..4a702398c --- /dev/null +++ b/gcc/testsuite/go.test/test/interface/embed.go @@ -0,0 +1,82 @@ +// $G $D/$F.go && $L $F.$A && ./$A.out + +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Check methods derived from embedded interface and *interface values. + +package main + +import "os" + +const Value = 1e12 + +type Inter interface { M() int64 } + +type T int64 +func (t T) M() int64 { return int64(t) } +var t = T(Value) +var pt = &t +var ti Inter = t +var pti = &ti + +type S struct { Inter } +var s = S{ ti } +var ps = &s + +type SP struct { *Inter } +var sp = SP{ &ti } +var psp = &sp + +var i Inter +var pi = &i + +var ok = true + +func check(s string, v int64) { + if v != Value { + println(s, v) + ok = false + } +} + +func main() { + check("t.M()", t.M()) + check("pt.M()", pt.M()) + check("ti.M()", ti.M()) + check("pti.M()", pti.M()) + check("s.M()", s.M()) + check("ps.M()", ps.M()) + check("sp.M()", sp.M()) + check("psp.M()", psp.M()) + + i = t + check("i = t; i.M()", i.M()) + check("i = t; pi.M()", pi.M()) + + i = pt + check("i = pt; i.M()", i.M()) + check("i = pt; pi.M()", pi.M()) + + i = s + check("i = s; i.M()", i.M()) + check("i = s; pi.M()", pi.M()) + + i = ps + check("i = ps; i.M()", i.M()) + check("i = ps; pi.M()", pi.M()) + + i = sp + check("i = sp; i.M()", i.M()) + check("i = sp; pi.M()", pi.M()) + + i = psp + check("i = psp; i.M()", i.M()) + check("i = psp; pi.M()", pi.M()) + + if !ok { + println("BUG: interface10") + os.Exit(1) + } +} |