mirror of
https://github.com/MontFerret/ferret.git
synced 2025-08-15 20:02:56 +02:00
Introduce base
utilities in integration tests for improved reuse and consistency. Refactor test cases to use base.Run
and base.Exec
. Add new shortcuts.go
for shared helpers.
This commit is contained in:
10
test/integration/vm/shortcuts.go
Normal file
10
test/integration/vm/shortcuts.go
Normal file
@@ -0,0 +1,10 @@
|
||||
package vm_test
|
||||
|
||||
import (
|
||||
"github.com/MontFerret/ferret/test/integration/base"
|
||||
)
|
||||
|
||||
type UseCase = base.TestCase
|
||||
|
||||
var NewCase = base.NewCase
|
||||
var Skip = base.Skip
|
@@ -8,6 +8,8 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/MontFerret/ferret/test/integration/base"
|
||||
|
||||
"github.com/MontFerret/ferret/pkg/compiler"
|
||||
"github.com/MontFerret/ferret/pkg/parser"
|
||||
"github.com/MontFerret/ferret/pkg/runtime"
|
||||
@@ -181,7 +183,7 @@ func TestMemberReservedWords(t *testing.T) {
|
||||
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
out, err := Exec(prog, true, vm.WithFunctions(c.Functions()))
|
||||
out, err := base.Exec(prog, true, vm.WithFunctions(c.Functions()))
|
||||
|
||||
So(err, ShouldBeNil)
|
||||
So(out, ShouldEqual, expected.String())
|
||||
|
@@ -3,6 +3,8 @@ package vm_test
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/MontFerret/ferret/test/integration/base"
|
||||
|
||||
. "github.com/smartystreets/goconvey/convey"
|
||||
|
||||
"github.com/MontFerret/ferret/pkg/compiler"
|
||||
@@ -42,7 +44,7 @@ func TestTernaryOperator(t *testing.T) {
|
||||
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
out, err := Run(p)
|
||||
out, err := base.Run(p)
|
||||
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
|
@@ -4,6 +4,8 @@ import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/MontFerret/ferret/test/integration/base"
|
||||
|
||||
"github.com/MontFerret/ferret/pkg/compiler"
|
||||
"github.com/MontFerret/ferret/pkg/runtime"
|
||||
"github.com/MontFerret/ferret/pkg/vm"
|
||||
@@ -94,7 +96,7 @@ func TestVariables(t *testing.T) {
|
||||
So(p, ShouldHaveSameTypeAs, &vm.Program{})
|
||||
|
||||
counter := -1
|
||||
out, err := Run(p, vm.WithFunction("COUNTER", func(ctx gocontext.Context, args ...runtime.Value) (runtime.Value, error) {
|
||||
out, err := base.Run(p, vm.WithFunction("COUNTER", func(ctx gocontext.Context, args ...runtime.Value) (runtime.Value, error) {
|
||||
counter++
|
||||
|
||||
return runtime.NewInt(counter), nil
|
||||
@@ -116,7 +118,7 @@ func TestVariables(t *testing.T) {
|
||||
So(p, ShouldHaveSameTypeAs, &vm.Program{})
|
||||
|
||||
counter := -1
|
||||
out, err := Run(p, vm.WithFunction("COUNTER", func(ctx gocontext.Context, args ...runtime.Value) (runtime.Value, error) {
|
||||
out, err := base.Run(p, vm.WithFunction("COUNTER", func(ctx gocontext.Context, args ...runtime.Value) (runtime.Value, error) {
|
||||
counter++
|
||||
|
||||
return runtime.NewInt(counter), nil
|
||||
|
Reference in New Issue
Block a user