1 // $G $D/$F.go && $L $F.$A && ./$A.out
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.
7 // check that big vs small, pointer vs not
8 // interface methods work.
12 type I interface { M() int64 }
14 type BigPtr struct { a, b, c, d int64 }
15 func (z *BigPtr) M() int64 { return z.a+z.b+z.c+z.d }
17 type SmallPtr struct { a int32 }
18 func (z *SmallPtr) M() int64 { return int64(z.a) }
21 func (z *IntPtr) M() int64 { return int64(*z) }
25 func test(name string, i I) {
34 var bigptr BigPtr = BigPtr{ 10000, 2000, 300, 45 }
35 var smallptr SmallPtr = SmallPtr{ 12345 }
36 var intptr IntPtr = 12345
38 // test("bigptr", bigptr)
39 test("&bigptr", &bigptr)
40 // test("smallptr", smallptr)
41 test("&smallptr", &smallptr)
42 // test("intptr", intptr)
43 test("&intptr", &intptr)
46 type Big struct { a, b, c, d int64 }
47 func (z Big) M() int64 { return z.a+z.b+z.c+z.d }
49 type Small struct { a int32 }
50 func (z Small) M() int64 { return int64(z.a) }
53 func (z Int) M() int64 { return int64(z) }
56 var big Big = Big{ 10000, 2000, 300, 45 }
57 var small Small = Small{ 12345 }
63 test("&small", &small)
73 println("BUG: interface4")