From 094c8474b7b34433e1a6cc41ec5f49896eef935b Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Mon, 23 Dec 2019 17:05:34 +0300 Subject: [PATCH] compiler: move tests from vm/tests These don't belong to VM as they compile some Go code and run it in a VM. One may call them integration tests, but I prefer to attribute them to compiler. Moving these tests into pkg/compiler also allows to properly count the compiler coverage they add: -ok github.com/CityOfZion/neo-go/pkg/compiler (cached) coverage: 69.7% of statements +ok github.com/CityOfZion/neo-go/pkg/compiler (cached) coverage: 84.2% of statements This change also fixes `contant` typo and removes fake packages exposed to the public by moving foo/bar/foobar into the testdata directory. --- pkg/{vm/tests => compiler}/assign_test.go | 2 +- pkg/{vm/tests => compiler}/binary_expr_test.go | 2 +- pkg/{vm/tests => compiler}/byte_conversion_test.go | 2 +- .../tests/contant_test.go => compiler/constant_test.go} | 2 +- pkg/{vm/tests => compiler}/for_test.go | 2 +- pkg/{vm/tests => compiler}/function_call_test.go | 2 +- pkg/{vm/tests => compiler}/if_test.go | 2 +- pkg/{vm/tests => compiler}/import_test.go | 8 ++++---- pkg/{vm/tests => compiler}/numeric_test.go | 2 +- pkg/{vm/tests => compiler}/slice_test.go | 2 +- pkg/{vm/tests => compiler}/struct_test.go | 2 +- pkg/{vm/tests => compiler}/syscall_test.go | 2 +- pkg/{vm/tests => compiler/testdata}/bar/bar.go | 0 pkg/{vm/tests => compiler/testdata}/foo/foo.go | 0 pkg/{vm/tests => compiler/testdata}/foobar/bar.go | 0 pkg/{vm/tests => compiler/testdata}/foobar/foo.go | 0 pkg/{vm/tests => compiler}/type_test.go | 2 +- pkg/{vm/tests => compiler}/util_test.go | 2 +- pkg/{vm/tests => compiler}/vm_test.go | 2 +- 19 files changed, 18 insertions(+), 18 deletions(-) rename pkg/{vm/tests => compiler}/assign_test.go (98%) rename pkg/{vm/tests => compiler}/binary_expr_test.go (99%) rename pkg/{vm/tests => compiler}/byte_conversion_test.go (97%) rename pkg/{vm/tests/contant_test.go => compiler/constant_test.go} (97%) rename pkg/{vm/tests => compiler}/for_test.go (99%) rename pkg/{vm/tests => compiler}/function_call_test.go (98%) rename pkg/{vm/tests => compiler}/if_test.go (98%) rename pkg/{vm/tests => compiler}/import_test.go (71%) rename pkg/{vm/tests => compiler}/numeric_test.go (92%) rename pkg/{vm/tests => compiler}/slice_test.go (96%) rename pkg/{vm/tests => compiler}/struct_test.go (99%) rename pkg/{vm/tests => compiler}/syscall_test.go (94%) rename pkg/{vm/tests => compiler/testdata}/bar/bar.go (100%) rename pkg/{vm/tests => compiler/testdata}/foo/foo.go (100%) rename pkg/{vm/tests => compiler/testdata}/foobar/bar.go (100%) rename pkg/{vm/tests => compiler/testdata}/foobar/foo.go (100%) rename pkg/{vm/tests => compiler}/type_test.go (93%) rename pkg/{vm/tests => compiler}/util_test.go (98%) rename pkg/{vm/tests => compiler}/vm_test.go (99%) diff --git a/pkg/vm/tests/assign_test.go b/pkg/compiler/assign_test.go similarity index 98% rename from pkg/vm/tests/assign_test.go rename to pkg/compiler/assign_test.go index 7882048ec..6f9a730cf 100644 --- a/pkg/vm/tests/assign_test.go +++ b/pkg/compiler/assign_test.go @@ -1,4 +1,4 @@ -package vm_test +package compiler_test import ( "math/big" diff --git a/pkg/vm/tests/binary_expr_test.go b/pkg/compiler/binary_expr_test.go similarity index 99% rename from pkg/vm/tests/binary_expr_test.go rename to pkg/compiler/binary_expr_test.go index 3cf5c242d..d3f5c0ab9 100644 --- a/pkg/vm/tests/binary_expr_test.go +++ b/pkg/compiler/binary_expr_test.go @@ -1,4 +1,4 @@ -package vm_test +package compiler_test import ( "math/big" diff --git a/pkg/vm/tests/byte_conversion_test.go b/pkg/compiler/byte_conversion_test.go similarity index 97% rename from pkg/vm/tests/byte_conversion_test.go rename to pkg/compiler/byte_conversion_test.go index 1a1fde605..1bbacade5 100644 --- a/pkg/vm/tests/byte_conversion_test.go +++ b/pkg/compiler/byte_conversion_test.go @@ -1,4 +1,4 @@ -package vm_test +package compiler_test import "testing" diff --git a/pkg/vm/tests/contant_test.go b/pkg/compiler/constant_test.go similarity index 97% rename from pkg/vm/tests/contant_test.go rename to pkg/compiler/constant_test.go index be6a2a796..9608e4e9c 100644 --- a/pkg/vm/tests/contant_test.go +++ b/pkg/compiler/constant_test.go @@ -1,4 +1,4 @@ -package vm_test +package compiler_test import ( "math/big" diff --git a/pkg/vm/tests/for_test.go b/pkg/compiler/for_test.go similarity index 99% rename from pkg/vm/tests/for_test.go rename to pkg/compiler/for_test.go index 2e3c15288..06dc95ea6 100644 --- a/pkg/vm/tests/for_test.go +++ b/pkg/compiler/for_test.go @@ -1,4 +1,4 @@ -package vm_test +package compiler_test import ( "math/big" diff --git a/pkg/vm/tests/function_call_test.go b/pkg/compiler/function_call_test.go similarity index 98% rename from pkg/vm/tests/function_call_test.go rename to pkg/compiler/function_call_test.go index 1ac71b011..03064a2d1 100644 --- a/pkg/vm/tests/function_call_test.go +++ b/pkg/compiler/function_call_test.go @@ -1,4 +1,4 @@ -package vm_test +package compiler_test import ( "math/big" diff --git a/pkg/vm/tests/if_test.go b/pkg/compiler/if_test.go similarity index 98% rename from pkg/vm/tests/if_test.go rename to pkg/compiler/if_test.go index c4483309e..91731460d 100644 --- a/pkg/vm/tests/if_test.go +++ b/pkg/compiler/if_test.go @@ -1,4 +1,4 @@ -package vm_test +package compiler_test import ( "math/big" diff --git a/pkg/vm/tests/import_test.go b/pkg/compiler/import_test.go similarity index 71% rename from pkg/vm/tests/import_test.go rename to pkg/compiler/import_test.go index fb831fcef..4ce80e5b0 100644 --- a/pkg/vm/tests/import_test.go +++ b/pkg/compiler/import_test.go @@ -1,4 +1,4 @@ -package vm_test +package compiler_test import ( "math/big" @@ -9,7 +9,7 @@ func TestImportFunction(t *testing.T) { src := ` package somethingelse - import "github.com/CityOfZion/neo-go/pkg/vm/tests/foo" + import "github.com/CityOfZion/neo-go/pkg/compiler/testdata/foo" func Main() int { i := foo.NewBar() @@ -23,7 +23,7 @@ func TestImportStruct(t *testing.T) { src := ` package somethingwedontcareabout - import "github.com/CityOfZion/neo-go/pkg/vm/tests/bar" + import "github.com/CityOfZion/neo-go/pkg/compiler/testdata/bar" func Main() int { b := bar.Bar{ @@ -39,7 +39,7 @@ func TestMultipleDirFileImport(t *testing.T) { src := ` package hello - import "github.com/CityOfZion/neo-go/pkg/vm/tests/foobar" + import "github.com/CityOfZion/neo-go/pkg/compiler/testdata/foobar" func Main() bool { ok := foobar.OtherBool() diff --git a/pkg/vm/tests/numeric_test.go b/pkg/compiler/numeric_test.go similarity index 92% rename from pkg/vm/tests/numeric_test.go rename to pkg/compiler/numeric_test.go index d2589dbf5..fba35d01a 100644 --- a/pkg/vm/tests/numeric_test.go +++ b/pkg/compiler/numeric_test.go @@ -1,4 +1,4 @@ -package vm_test +package compiler_test import ( "math/big" diff --git a/pkg/vm/tests/slice_test.go b/pkg/compiler/slice_test.go similarity index 96% rename from pkg/vm/tests/slice_test.go rename to pkg/compiler/slice_test.go index 8d0d67f9d..84948433d 100644 --- a/pkg/vm/tests/slice_test.go +++ b/pkg/compiler/slice_test.go @@ -1,4 +1,4 @@ -package vm_test +package compiler_test import ( "math/big" diff --git a/pkg/vm/tests/struct_test.go b/pkg/compiler/struct_test.go similarity index 99% rename from pkg/vm/tests/struct_test.go rename to pkg/compiler/struct_test.go index d739a935f..073367207 100644 --- a/pkg/vm/tests/struct_test.go +++ b/pkg/compiler/struct_test.go @@ -1,4 +1,4 @@ -package vm_test +package compiler_test import ( "math/big" diff --git a/pkg/vm/tests/syscall_test.go b/pkg/compiler/syscall_test.go similarity index 94% rename from pkg/vm/tests/syscall_test.go rename to pkg/compiler/syscall_test.go index a19e9dcb3..4e62721b3 100644 --- a/pkg/vm/tests/syscall_test.go +++ b/pkg/compiler/syscall_test.go @@ -1,4 +1,4 @@ -package vm_test +package compiler_test import ( "testing" diff --git a/pkg/vm/tests/bar/bar.go b/pkg/compiler/testdata/bar/bar.go similarity index 100% rename from pkg/vm/tests/bar/bar.go rename to pkg/compiler/testdata/bar/bar.go diff --git a/pkg/vm/tests/foo/foo.go b/pkg/compiler/testdata/foo/foo.go similarity index 100% rename from pkg/vm/tests/foo/foo.go rename to pkg/compiler/testdata/foo/foo.go diff --git a/pkg/vm/tests/foobar/bar.go b/pkg/compiler/testdata/foobar/bar.go similarity index 100% rename from pkg/vm/tests/foobar/bar.go rename to pkg/compiler/testdata/foobar/bar.go diff --git a/pkg/vm/tests/foobar/foo.go b/pkg/compiler/testdata/foobar/foo.go similarity index 100% rename from pkg/vm/tests/foobar/foo.go rename to pkg/compiler/testdata/foobar/foo.go diff --git a/pkg/vm/tests/type_test.go b/pkg/compiler/type_test.go similarity index 93% rename from pkg/vm/tests/type_test.go rename to pkg/compiler/type_test.go index af3ed280c..c8db6fb0c 100644 --- a/pkg/vm/tests/type_test.go +++ b/pkg/compiler/type_test.go @@ -1,4 +1,4 @@ -package vm_test +package compiler_test import "testing" diff --git a/pkg/vm/tests/util_test.go b/pkg/compiler/util_test.go similarity index 98% rename from pkg/vm/tests/util_test.go rename to pkg/compiler/util_test.go index 2da750d91..23ddd427f 100644 --- a/pkg/vm/tests/util_test.go +++ b/pkg/compiler/util_test.go @@ -1,4 +1,4 @@ -package vm_test +package compiler_test import ( "testing" diff --git a/pkg/vm/tests/vm_test.go b/pkg/compiler/vm_test.go similarity index 99% rename from pkg/vm/tests/vm_test.go rename to pkg/compiler/vm_test.go index fa4955187..4e0312c03 100644 --- a/pkg/vm/tests/vm_test.go +++ b/pkg/compiler/vm_test.go @@ -1,4 +1,4 @@ -package vm_test +package compiler_test import ( "fmt"