summaryrefslogtreecommitdiff
path: root/test/method3.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2009-01-08 18:06:06 -0800
committerRuss Cox <rsc@golang.org>2009-01-08 18:06:06 -0800
commit53d37aba79b02dd8897c40bd9cc25ba836ff74b5 (patch)
tree91ce53f7041c7848d765b879858a096eebec45d6 /test/method3.go
parent24e58e9d54ddbecc43f286e4fa69c88ffc123d84 (diff)
downloadgo-53d37aba79b02dd8897c40bd9cc25ba836ff74b5.tar.gz
second pass on interface fixes and tests.
R=ken OCL=22370 CL=22372
Diffstat (limited to 'test/method3.go')
-rw-r--r--test/method3.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/method3.go b/test/method3.go
new file mode 100644
index 000000000..491bcdad3
--- /dev/null
+++ b/test/method3.go
@@ -0,0 +1,25 @@
+// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG method3
+
+// 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.
+
+// test that methods on slices work
+
+package main
+
+type T [] int
+func (t T) Len() int { return len(t) }
+
+type I interface {
+ Len() int
+}
+
+func main() {
+ var t T = T{0,1,2,3,4};
+ var i I;
+ i = t;
+ if i.Len() != 5 {
+ panicln("length", i.Len());
+ }
+}