compiler: add support for new language features of Go 1.17

This commit is contained in:
Ayke van Laethem
2021-08-15 02:29:27 +02:00
committed by Ron Evans
parent 8e88e560a1
commit 255f35671d
11 changed files with 361 additions and 12 deletions
+15 -4
View File
@@ -9,6 +9,7 @@ import (
"testing"
"github.com/tinygo-org/tinygo/compileopts"
"github.com/tinygo-org/tinygo/goenv"
"github.com/tinygo-org/tinygo/loader"
"tinygo.org/x/go-llvm"
)
@@ -16,6 +17,11 @@ import (
// Pass -update to go test to update the output of the test files.
var flagUpdate = flag.Bool("update", false, "update tests based on test output")
type testCase struct {
file string
target string
}
// Basic tests for the compiler. Build some Go files and compare the output with
// the expected LLVM IR for regression testing.
func TestCompiler(t *testing.T) {
@@ -34,10 +40,7 @@ func TestCompiler(t *testing.T) {
t.Skip("compiler tests require LLVM 11 or above, got LLVM ", llvm.Version)
}
tests := []struct {
file string
target string
}{
tests := []testCase{
{"basic.go", ""},
{"pointer.go", ""},
{"slice.go", ""},
@@ -52,6 +55,14 @@ func TestCompiler(t *testing.T) {
{"intrinsics.go", "wasm"},
}
_, minor, err := goenv.GetGorootVersion(goenv.Get("GOROOT"))
if err != nil {
t.Fatal("could not read Go version:", err)
}
if minor >= 17 {
tests = append(tests, testCase{"go1.17.go", ""})
}
for _, tc := range tests {
name := tc.file
targetString := "wasm"