summaryrefslogtreecommitdiffstats
path: root/llgo/test/execution/interfaces/wordsize.go
diff options
context:
space:
mode:
Diffstat (limited to 'llgo/test/execution/interfaces/wordsize.go')
-rw-r--r--llgo/test/execution/interfaces/wordsize.go40
1 files changed, 40 insertions, 0 deletions
diff --git a/llgo/test/execution/interfaces/wordsize.go b/llgo/test/execution/interfaces/wordsize.go
new file mode 100644
index 00000000000..e2de5d54895
--- /dev/null
+++ b/llgo/test/execution/interfaces/wordsize.go
@@ -0,0 +1,40 @@
+// RUN: llgo -o %t %s
+// RUN: %t 2>&1 | FileCheck %s
+
+// CHECK: StringStringer(abc)
+// CHECK-NEXT: abc 1 2 3
+
+package main
+
+type Stringer interface {
+ String() string
+}
+
+type StringStringer string
+
+func (s StringStringer) String() string {
+ return "StringStringer(" + string(s) + ")"
+}
+
+func (s StringStringer) MethodWithArgs(a, b, c int) {
+ println(s, a, b, c)
+}
+
+type I interface {
+ MethodWithArgs(a, b, c int)
+}
+
+func testLargerThanWord() {
+ // string is larger than a word. Make sure it works
+ // well as a method receiver when using interfaces.
+ var s Stringer = StringStringer("abc")
+ println(s.String())
+
+ // Test calling a method which takes parameters
+ // beyond the receiver.
+ s.(I).MethodWithArgs(1, 2, 3)
+}
+
+func main() {
+ testLargerThanWord()
+}
OpenPOWER on IntegriCloud