1
0
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:
Tim Voronov
2025-07-02 13:31:02 -04:00
parent 2f25e4e4be
commit 74a2ced589
4 changed files with 20 additions and 4 deletions

View 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

View File

@@ -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())

View File

@@ -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)

View File

@@ -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