]> Cypherpunks.ru repositories - gostls13.git/blob - test/method3.go
cmd/compile/internal/inline: score call sites exposed by inlines
[gostls13.git] / test / method3.go
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
9 package main
10
11 type T []int
12
13 func (t T) Len() int { return len(t) }
14
15 type I interface {
16         Len() int
17 }
18
19 func 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 }