summaryrefslogtreecommitdiffstats
path: root/llgo/test/execution/functions
diff options
context:
space:
mode:
Diffstat (limited to 'llgo/test/execution/functions')
-rw-r--r--llgo/test/execution/functions/compare.go26
-rw-r--r--llgo/test/execution/functions/multivalue.go28
-rw-r--r--llgo/test/execution/functions/unreachable.go53
3 files changed, 107 insertions, 0 deletions
diff --git a/llgo/test/execution/functions/compare.go b/llgo/test/execution/functions/compare.go
new file mode 100644
index 00000000000..9daa062efe9
--- /dev/null
+++ b/llgo/test/execution/functions/compare.go
@@ -0,0 +1,26 @@
+// RUN: llgo -o %t %s
+// RUN: %t 2>&1 | FileCheck %s
+
+// CHECK: true
+// CHECK-NEXT: false
+// CHECK-NEXT: true
+// CHECK-NEXT: false
+// CHECK-NEXT: false
+// CHECK-NEXT: true
+// CHECK-NEXT: false
+// CHECK-NEXT: true
+
+package main
+
+func main() {
+ var f func()
+ println(f == nil)
+ println(f != nil)
+ println(nil == f)
+ println(nil != f)
+ f = func() {}
+ println(f == nil)
+ println(f != nil)
+ println(nil == f)
+ println(nil != f)
+}
diff --git a/llgo/test/execution/functions/multivalue.go b/llgo/test/execution/functions/multivalue.go
new file mode 100644
index 00000000000..a3ce79b3fc0
--- /dev/null
+++ b/llgo/test/execution/functions/multivalue.go
@@ -0,0 +1,28 @@
+// RUN: llgo -o %t %s
+// RUN: %t 2>&1 | FileCheck %s
+
+// CHECK: 1
+// CHECK-NEXT: 20
+// CHECK-NEXT: extra: 10
+
+package main
+
+func swap(a, b int) (int, int) {
+ return b, a
+}
+
+func sub(a, b int) int {
+ return a - b
+}
+
+func printint(a int, extra ...int) {
+ println(a)
+ for _, b := range extra {
+ println("extra:", b)
+ }
+}
+
+func main() {
+ println(sub(swap(1, 2)))
+ printint(swap(10, 20))
+}
diff --git a/llgo/test/execution/functions/unreachable.go b/llgo/test/execution/functions/unreachable.go
new file mode 100644
index 00000000000..436012c4e41
--- /dev/null
+++ b/llgo/test/execution/functions/unreachable.go
@@ -0,0 +1,53 @@
+// RUN: llgo -o %t %s
+// RUN: %t 2>&1 | FileCheck %s
+
+// CHECK: f1
+// CHECK-NEXT: f2
+// CHECK-NEXT: f3
+// CHECK-NEXT: f4
+// CHECK-NEXT: 123
+
+package main
+
+func f1() {
+ if true {
+ println("f1")
+ return
+ }
+ for {
+ }
+}
+
+func f2() {
+ defer func() { println("f2") }()
+ if true {
+ return
+ }
+ for {
+ }
+}
+
+func f3() int {
+ if true {
+ println("f3")
+ return 123
+ }
+ for {
+ }
+}
+
+func f4() int {
+ defer func() { println("f4") }()
+ if true {
+ return 123
+ }
+ for {
+ }
+}
+
+func main() {
+ f1()
+ f2()
+ f3()
+ println(f4())
+}
OpenPOWER on IntegriCloud