codekingpro/portable-devtools
114k
1// run2 3// Copyright 2009 The Go Authors. All rights reserved.4// Use of this source code is governed by a BSD-style5// license that can be found in the LICENSE file.6 7// Test methods derived from embedded interface values.8 9package main10 11import "os"12 13const Value = 1e1214 15type Inter interface { M() int64 }16 17type T int6418func (t T) M() int64 { return int64(t) }19var t = T(Value)20var pt = &t21var ti Inter = t22 23type S struct { Inter }24var s = S{ ti }25var ps = &s26 27var i Inter28 29var ok = true30 31func check(s string, v int64) {32 if v != Value {33 println(s, v)34 ok = false35 }36}37 38func main() {39 check("t.M()", t.M())40 check("pt.M()", pt.M())41 check("ti.M()", ti.M())42 check("s.M()", s.M())43 check("ps.M()", ps.M())44 45 i = t46 check("i = t; i.M()", i.M())47 48 i = pt49 check("i = pt; i.M()", i.M())50 51 i = s52 check("i = s; i.M()", i.M())53 54 i = ps55 check("i = ps; i.M()", i.M())56 57 if !ok {58 println("BUG: interface10")59 os.Exit(1)60 }61}62 