Russ Cox | e512481 | 2009-01-08 18:06:06 -0800 | [diff] [blame] | 1 | // $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG method3 |
| 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 that methods on slices work |
| 8 | |
| 9 | package main |
| 10 | |
Russ Cox | 839a684 | 2009-01-20 14:40:40 -0800 | [diff] [blame] | 11 | type T [] int |
Russ Cox | e512481 | 2009-01-08 18:06:06 -0800 | [diff] [blame] | 12 | func (t T) Len() int { return len(t) } |
| 13 | |
Russ Cox | 839a684 | 2009-01-20 14:40:40 -0800 | [diff] [blame] | 14 | type I interface { |
Russ Cox | e512481 | 2009-01-08 18:06:06 -0800 | [diff] [blame] | 15 | Len() int |
| 16 | } |
| 17 | |
| 18 | func main() { |
Russ Cox | be2edb5 | 2009-03-03 08:39:12 -0800 | [diff] [blame] | 19 | var t T = T{0,1,2,3,4}; |
Russ Cox | e512481 | 2009-01-08 18:06:06 -0800 | [diff] [blame] | 20 | var i I; |
| 21 | i = t; |
| 22 | if i.Len() != 5 { |
| 23 | panicln("length", i.Len()); |
| 24 | } |
| 25 | } |