1// run 2 3// Copyright 2009 The Go Authors. All rights reserved. 4// Use of this source code is governed by a BSD-style 5// license that can be found in the LICENSE file. 6 7// Test methods on slices. 8 9package main 10 11type T []int 12 13func (t T) Len() int { return len(t) } 14 15type I interface { 16 Len() int 17} 18 19func main() { 20 var t T = T{0, 1, 2, 3, 4} 21 var i I 22 i = t 23 if i.Len() != 5 { 24 println("i.Len", i.Len()) 25 panic("fail") 26 } 27 if T.Len(t) != 5 { 28 println("T.Len", T.Len(t)) 29 panic("fail") 30 } 31 if (*T).Len(&t) != 5 { 32 println("(*T).Len", (*T).Len(&t)) 33 panic("fail") 34 } 35} 36