diff --git a/pkg/vm/tests/assign_test.go b/pkg/vm/tests/assign_test.go index 252b92c08..5c2460d41 100644 --- a/pkg/vm/tests/assign_test.go +++ b/pkg/vm/tests/assign_test.go @@ -1,6 +1,9 @@ package vm_test -import "math/big" +import ( + "math/big" + "testing" +) var assignTestCases = []testCase{ { @@ -126,3 +129,7 @@ var assignTestCases = []testCase{ big.NewInt(3), }, } + +func TestAssignments(t *testing.T) { + run_testcases(t, assignTestCases) +} diff --git a/pkg/vm/tests/binary_expr_test.go b/pkg/vm/tests/binary_expr_test.go index b836d97ec..8abd5ccd9 100644 --- a/pkg/vm/tests/binary_expr_test.go +++ b/pkg/vm/tests/binary_expr_test.go @@ -1,6 +1,9 @@ package vm_test -import "math/big" +import ( + "math/big" + "testing" +) var binaryExprTestCases = []testCase{ { @@ -114,3 +117,7 @@ var binaryExprTestCases = []testCase{ big.NewInt(0), }, } + +func TestBinaryExprs(t *testing.T) { + run_testcases(t, binaryExprTestCases) +} diff --git a/pkg/vm/tests/numeric_test.go b/pkg/vm/tests/numeric_test.go index b53f89b8b..53fc3e722 100644 --- a/pkg/vm/tests/numeric_test.go +++ b/pkg/vm/tests/numeric_test.go @@ -1,6 +1,9 @@ package vm_test -import "math/big" +import ( + "math/big" + "testing" +) var numericTestCases = []testCase{ { @@ -16,3 +19,7 @@ var numericTestCases = []testCase{ big.NewInt(6), }, } + +func TestNumericExprs(t *testing.T) { + run_testcases(t, numericTestCases) +} diff --git a/pkg/vm/tests/struct_test.go b/pkg/vm/tests/struct_test.go index b74e33f36..759396889 100644 --- a/pkg/vm/tests/struct_test.go +++ b/pkg/vm/tests/struct_test.go @@ -2,6 +2,7 @@ package vm_test import ( "math/big" + "testing" "github.com/CityOfZion/neo-go/pkg/vm" ) @@ -237,3 +238,7 @@ var structTestCases = []testCase{ big.NewInt(14), }, } + +func TestStructs(t *testing.T) { + run_testcases(t, structTestCases) +} diff --git a/pkg/vm/tests/vm_test.go b/pkg/vm/tests/vm_test.go index ac504c945..4ce507dc1 100644 --- a/pkg/vm/tests/vm_test.go +++ b/pkg/vm/tests/vm_test.go @@ -16,6 +16,12 @@ type testCase struct { result interface{} } +func run_testcases(t *testing.T, tcases []testCase) { + for _, tcase := range tcases { + t.Run(tcase.name, func(t *testing.T) {eval(t, tcase.src, tcase.result)}) + } +} + func eval(t *testing.T, src string, result interface{}) { vm := vmAndCompile(t, src) vm.Run()