github.com/llvm-mirror/llgo@v0.0.0-20190322182713-bf6f0a60fce1/test/execution/interfaces/wordsize.go (about)

     1  // RUN: llgo -o %t %s
     2  // RUN: %t 2>&1 | FileCheck %s
     3  
     4  // CHECK: StringStringer(abc)
     5  // CHECK-NEXT: abc 1 2 3
     6  
     7  package main
     8  
     9  type Stringer interface {
    10  	String() string
    11  }
    12  
    13  type StringStringer string
    14  
    15  func (s StringStringer) String() string {
    16  	return "StringStringer(" + string(s) + ")"
    17  }
    18  
    19  func (s StringStringer) MethodWithArgs(a, b, c int) {
    20  	println(s, a, b, c)
    21  }
    22  
    23  type I interface {
    24  	MethodWithArgs(a, b, c int)
    25  }
    26  
    27  func testLargerThanWord() {
    28  	// string is larger than a word. Make sure it works
    29  	// well as a method receiver when using interfaces.
    30  	var s Stringer = StringStringer("abc")
    31  	println(s.String())
    32  
    33  	// Test calling a method which takes parameters
    34  	// beyond the receiver.
    35  	s.(I).MethodWithArgs(1, 2, 3)
    36  }
    37  
    38  func main() {
    39  	testLargerThanWord()
    40  }