summaryrefslogtreecommitdiffstats
path: root/llgo/test
diff options
context:
space:
mode:
Diffstat (limited to 'llgo/test')
-rw-r--r--llgo/test/CMakeLists.txt1
-rw-r--r--llgo/test/lit.cfg3
-rw-r--r--llgo/test/llgoi/Inputs/src/bar/answer.go5
-rw-r--r--llgo/test/llgoi/Inputs/src/foo/answer.go7
-rw-r--r--llgo/test/llgoi/Inputs/src/foo_cgo/answer.go8
-rw-r--r--llgo/test/llgoi/arith.test4
-rw-r--r--llgo/test/llgoi/import-binary.test5
-rw-r--r--llgo/test/llgoi/import-source.test14
-rw-r--r--llgo/test/llgoi/interfaces.test19
-rw-r--r--llgo/test/llgoi/maps.test22
-rw-r--r--llgo/test/llgoi/panic.test16
-rw-r--r--llgo/test/llgoi/vars.test29
12 files changed, 132 insertions, 1 deletions
diff --git a/llgo/test/CMakeLists.txt b/llgo/test/CMakeLists.txt
index 641ade8322a..c8a346f3db6 100644
--- a/llgo/test/CMakeLists.txt
+++ b/llgo/test/CMakeLists.txt
@@ -9,6 +9,7 @@ add_lit_testsuite(check-llgo "Running the llgo regression tests"
FileCheck
count
llgo
+ llgoi
libgo
not
)
diff --git a/llgo/test/lit.cfg b/llgo/test/lit.cfg
index e4639abdf10..a94e33e7a17 100644
--- a/llgo/test/lit.cfg
+++ b/llgo/test/lit.cfg
@@ -3,13 +3,14 @@ import os
import sys
config.name = 'llgo'
-config.suffixes = ['.go']
+config.suffixes = ['.go', '.test']
config.test_format = lit.formats.ShTest()
config.test_source_root = config.llvm_src_root + '/tools/llgo/test'
config.test_exec_root = config.llvm_obj_root + '/tools/llgo/test'
config.excludes = ['Inputs']
config.substitutions.append((r"\bllgo\b", config.llvm_obj_root + '/bin/llgo -static-libgo'))
+config.substitutions.append((r"\bllgoi\b", config.llvm_obj_root + '/bin/llgoi'))
config.substitutions.append((r"\bFileCheck\b", config.llvm_obj_root + '/bin/FileCheck'))
config.substitutions.append((r"\bcount\b", config.llvm_obj_root + '/bin/count'))
config.substitutions.append((r"\bnot\b", config.llvm_obj_root + '/bin/not'))
diff --git a/llgo/test/llgoi/Inputs/src/bar/answer.go b/llgo/test/llgoi/Inputs/src/bar/answer.go
new file mode 100644
index 00000000000..7f1bd022ac5
--- /dev/null
+++ b/llgo/test/llgoi/Inputs/src/bar/answer.go
@@ -0,0 +1,5 @@
+package bar
+
+func Answer() int {
+ return 42
+}
diff --git a/llgo/test/llgoi/Inputs/src/foo/answer.go b/llgo/test/llgoi/Inputs/src/foo/answer.go
new file mode 100644
index 00000000000..1593e36491e
--- /dev/null
+++ b/llgo/test/llgoi/Inputs/src/foo/answer.go
@@ -0,0 +1,7 @@
+package foo
+
+import "bar"
+
+func Answer() int {
+ return bar.Answer()
+}
diff --git a/llgo/test/llgoi/Inputs/src/foo_cgo/answer.go b/llgo/test/llgoi/Inputs/src/foo_cgo/answer.go
new file mode 100644
index 00000000000..5fe8a31c34c
--- /dev/null
+++ b/llgo/test/llgoi/Inputs/src/foo_cgo/answer.go
@@ -0,0 +1,8 @@
+package foo_cgo
+
+// #include <stdint.h>
+import "C"
+
+func Answer() C.uint64_t {
+ return 42
+}
diff --git a/llgo/test/llgoi/arith.test b/llgo/test/llgoi/arith.test
new file mode 100644
index 00000000000..83b30d9d561
--- /dev/null
+++ b/llgo/test/llgoi/arith.test
@@ -0,0 +1,4 @@
+// RUN: llgoi < %s | FileCheck %s
+
+1 + 1
+// CHECK: #0 untyped int = 2
diff --git a/llgo/test/llgoi/import-binary.test b/llgo/test/llgoi/import-binary.test
new file mode 100644
index 00000000000..542054e11f0
--- /dev/null
+++ b/llgo/test/llgoi/import-binary.test
@@ -0,0 +1,5 @@
+// RUN: llgoi < %s | FileCheck %s
+
+import "fmt"
+fmt.Println(1, "two", 3)
+// CHECK: 1 two 3
diff --git a/llgo/test/llgoi/import-source.test b/llgo/test/llgoi/import-source.test
new file mode 100644
index 00000000000..22cf57487e3
--- /dev/null
+++ b/llgo/test/llgoi/import-source.test
@@ -0,0 +1,14 @@
+// RUN: env GOPATH=%S/Inputs llgoi < %s | FileCheck %s
+
+// make sure user symbols do not conflict with imported source package
+Answer := 1
+
+import "foo"
+// CHECK: # bar
+// CHECK: # foo
+
+foo.Answer()
+// CHECK: #0 int = 42
+
+import "foo_cgo"
+// CHECK: foo_cgo: cannot load cgo package
diff --git a/llgo/test/llgoi/interfaces.test b/llgo/test/llgoi/interfaces.test
new file mode 100644
index 00000000000..bc12b09ab66
--- /dev/null
+++ b/llgo/test/llgoi/interfaces.test
@@ -0,0 +1,19 @@
+// RUN: llgoi < %s | FileCheck %s
+
+import "errors"
+err := errors.New("foo")
+// CHECK: err error {{.*}} = foo
+
+err.(interface{Foo()})
+// CHECK: panic: interface conversion
+
+_, _ := err.(interface{Foo()})
+// CHECK: #0 interface{Foo()} (<nil>) = <nil>
+// CHECK: #1 bool = false
+
+err.(interface{Error() string})
+// CHECK: #0 interface{Error() string} {{.*}} = foo
+
+_, _ := err.(interface{Error() string})
+// CHECK: #0 interface{Error() string} {{.*}} = foo
+// CHECK: #1 bool = true
diff --git a/llgo/test/llgoi/maps.test b/llgo/test/llgoi/maps.test
new file mode 100644
index 00000000000..8678104d3e8
--- /dev/null
+++ b/llgo/test/llgoi/maps.test
@@ -0,0 +1,22 @@
+// RUN: llgoi < %s | FileCheck %s
+
+m := make(map[int]int)
+// CHECK: m map[int]int = map[]
+
+m[0]
+// CHECK: #0 int = 0
+
+_, _ := m[0]
+// CHECK: #0 int = 0
+// CHECK: #1 bool = false
+
+func() {
+ m[0] = 1
+}()
+
+m[0]
+// CHECK: #0 int = 1
+
+_, _ := m[0]
+// CHECK: #0 int = 1
+// CHECK: #1 bool = true
diff --git a/llgo/test/llgoi/panic.test b/llgo/test/llgoi/panic.test
new file mode 100644
index 00000000000..65ecd7b085a
--- /dev/null
+++ b/llgo/test/llgoi/panic.test
@@ -0,0 +1,16 @@
+// RUN: llgoi < %s | FileCheck %s
+
+panic("msg")
+// CHECK: panic: msg
+
+import "fmt"
+func() {
+ defer func() {
+ r := recover()
+ fmt.Println("recovered", r)
+ }()
+ panic("msg")
+}()
+// CHECK-NOT: {{^}}panic:
+// CHECK: recovered msg
+// CHECK-NOT: {{^}}panic:
diff --git a/llgo/test/llgoi/vars.test b/llgo/test/llgoi/vars.test
new file mode 100644
index 00000000000..1e1f0635636
--- /dev/null
+++ b/llgo/test/llgoi/vars.test
@@ -0,0 +1,29 @@
+// RUN: llgoi < %s 2>&1 | FileCheck %s
+
+x := 3
+// CHECK: x untyped int = 3
+
+x + x
+// CHECK: #0 int = 6
+
+x * x
+// CHECK: #0 int = 9
+
+x = 4
+x + x
+// CHECK: #0 int = 8
+
+x := true
+// CHECK: cannot assign {{.*}} to x (variable of type int)
+
+x, y := func() (int, int) {
+ return 1, 2
+}()
+// CHECK: x int = 1
+// CHECK: y int = 2
+
+x, _ = func() (int, int) {
+ return 3, 4
+}()
+x
+// CHECK: #0 int = 3
OpenPOWER on IntegriCloud