diff --git a/test/integration/base/use_case.go b/test/integration/base/test_case.go similarity index 82% rename from test/integration/base/use_case.go rename to test/integration/base/test_case.go index 60592778..cd76ef2d 100644 --- a/test/integration/base/use_case.go +++ b/test/integration/base/test_case.go @@ -6,7 +6,7 @@ import ( . "github.com/smartystreets/goconvey/convey" ) -type UseCase struct { +type TestCase struct { Expression string Expected any PreAssertion Assertion @@ -16,8 +16,8 @@ type UseCase struct { RawOutput bool } -func NewCase(expression string, expected any, assertion Assertion, desc ...string) UseCase { - return UseCase{ +func NewCase(expression string, expected any, assertion Assertion, desc ...string) TestCase { + return TestCase{ Expression: expression, Expected: expected, Assertions: []Assertion{assertion}, @@ -25,7 +25,7 @@ func NewCase(expression string, expected any, assertion Assertion, desc ...strin } } -func Skip(uc UseCase) UseCase { +func Skip(uc TestCase) TestCase { uc.Skip = true return uc } diff --git a/test/integration/benchmarks/bench_for_sort_test.go b/test/integration/benchmarks/bench_for_sort_test.go index ae1951a9..fe68b004 100644 --- a/test/integration/benchmarks/bench_for_sort_test.go +++ b/test/integration/benchmarks/bench_for_sort_test.go @@ -2,8 +2,6 @@ package benchmarks_test import ( "testing" - - . "github.com/MontFerret/ferret/test/integration/base" ) func BenchmarkForSort(b *testing.B) { diff --git a/test/integration/benchmarks/bench_func_test.go b/test/integration/benchmarks/bench_func_test.go index 80e0b2e8..d75a6a9c 100644 --- a/test/integration/benchmarks/bench_func_test.go +++ b/test/integration/benchmarks/bench_func_test.go @@ -6,8 +6,6 @@ import ( "github.com/MontFerret/ferret/pkg/runtime" "github.com/MontFerret/ferret/pkg/vm" - - . "github.com/MontFerret/ferret/test/integration/base" ) func BenchmarkFunctionCall(b *testing.B) { diff --git a/test/integration/bytecode/shortcuts.go b/test/integration/bytecode/shortcuts.go index ab8875b9..0dfc0b0f 100644 --- a/test/integration/bytecode/shortcuts.go +++ b/test/integration/bytecode/shortcuts.go @@ -6,7 +6,7 @@ import ( ) type BC = []vm.Instruction -type UseCase = base.UseCase +type UseCase = base.TestCase var I = vm.NewInstruction var C = vm.NewConstant diff --git a/test/integration/vm/helpers.go b/test/integration/vm/helpers.go index dd14380b..305fe647 100644 --- a/test/integration/vm/helpers.go +++ b/test/integration/vm/helpers.go @@ -3,14 +3,15 @@ package vm_test import ( "context" + "github.com/MontFerret/ferret/test/integration/base" + "github.com/MontFerret/ferret/pkg/runtime" - . "github.com/MontFerret/ferret/test/integration/base" ) func ForWhileHelpers() runtime.Functions { return runtime.NewFunctionsFromMap(map[string]runtime.Function{ - "UNTIL": StateFn[int](func(ctx context.Context, args ...runtime.Value) (runtime.Value, error) { - state := GetFnState[int](ctx) + "UNTIL": base.StateFn[int](func(ctx context.Context, args ...runtime.Value) (runtime.Value, error) { + state := base.GetFnState[int](ctx) untilCounter := state.Get() if untilCounter < int(runtime.ToIntSafe(ctx, args[0])) { @@ -24,8 +25,8 @@ func ForWhileHelpers() runtime.Functions { }, func(ctx context.Context) int { return 0 }), - "COUNTER": StateFn[int](func(ctx context.Context, args ...runtime.Value) (runtime.Value, error) { - state := GetFnState[int](ctx) + "COUNTER": base.StateFn[int](func(ctx context.Context, args ...runtime.Value) (runtime.Value, error) { + state := base.GetFnState[int](ctx) counter := state.Get() counter++ diff --git a/test/integration/vm/vm_case.go b/test/integration/vm/vm_case.go index 25a7076e..752718a7 100644 --- a/test/integration/vm/vm_case.go +++ b/test/integration/vm/vm_case.go @@ -5,11 +5,12 @@ import ( "strings" "testing" + "github.com/MontFerret/ferret/test/integration/base" + . "github.com/smartystreets/goconvey/convey" "github.com/MontFerret/ferret/pkg/compiler" "github.com/MontFerret/ferret/pkg/vm" - . "github.com/MontFerret/ferret/test/integration/base" ) func Case(expression string, expected any, desc ...string) UseCase { @@ -45,7 +46,7 @@ func SkipCaseRuntimeErrorAs(expression string, expected error, desc ...string) U } func CaseCompilationError(expression string, desc ...string) UseCase { - return NewCase(expression, nil, ShouldBeCompilationError, desc...) + return NewCase(expression, nil, base.ShouldBeCompilationError, desc...) } func SkipCaseCompilationError(expression string, desc ...string) UseCase { @@ -73,7 +74,7 @@ func SkipCaseArray(expression string, expected []any, desc ...string) UseCase { } func CaseItems(expression string, expected ...any) UseCase { - return NewCase(expression, expected, ShouldHaveSameItems) + return NewCase(expression, expected, base.ShouldHaveSameItems) } func CaseFn(expression string, assertion func(actual any, expected ...any) string) UseCase { @@ -118,7 +119,7 @@ func RunUseCasesWith(t *testing.T, c *compiler.Compiler, useCases []UseCase, opt Convey(useCase.Expression, t, func() { prog, err := c.Compile(useCase.Expression) - if !ArePtrsEqual(useCase.PreAssertion, ShouldBeCompilationError) { + if !base.ArePtrsEqual(useCase.PreAssertion, base.ShouldBeCompilationError) { So(err, ShouldBeNil) } else { So(err, ShouldBeError) @@ -132,10 +133,10 @@ func RunUseCasesWith(t *testing.T, c *compiler.Compiler, useCases []UseCase, opt options = append(options, opts...) expected := useCase.Expected - actual, err := Exec(prog, useCase.RawOutput, options...) + actual, err := base.Exec(prog, useCase.RawOutput, options...) for _, assertion := range useCase.Assertions { - if ArePtrsEqual(assertion, ShouldBeError) { + if base.ArePtrsEqual(assertion, ShouldBeError) { So(err, ShouldBeError) if expected != nil { @@ -149,13 +150,13 @@ func RunUseCasesWith(t *testing.T, c *compiler.Compiler, useCases []UseCase, opt So(err, ShouldBeNil) - if ArePtrsEqual(assertion, ShouldEqualJSON) { + if base.ArePtrsEqual(assertion, ShouldEqualJSON) { expectedJ, err := j.Marshal(expected) So(err, ShouldBeNil) So(actual, ShouldEqualJSON, string(expectedJ)) - } else if ArePtrsEqual(assertion, ShouldHaveSameItems) { - So(actual, ShouldHaveSameItems, expected) - } else if ArePtrsEqual(assertion, ShouldBeNil) { + } else if base.ArePtrsEqual(assertion, base.ShouldHaveSameItems) { + So(actual, base.ShouldHaveSameItems, expected) + } else if base.ArePtrsEqual(assertion, ShouldBeNil) { So(actual, ShouldBeNil) } else { So(actual, assertion, expected) diff --git a/test/integration/vm/vm_for_do_while_test.go b/test/integration/vm/vm_for_do_while_test.go index bd8431ea..4fedaccc 100644 --- a/test/integration/vm/vm_for_do_while_test.go +++ b/test/integration/vm/vm_for_do_while_test.go @@ -3,8 +3,6 @@ package vm_test import ( "testing" - . "github.com/MontFerret/ferret/test/integration/base" - "github.com/MontFerret/ferret/pkg/vm" ) diff --git a/test/integration/vm/vm_for_in_collect_agg_test.go b/test/integration/vm/vm_for_in_collect_agg_test.go index 60e01393..4c16b20c 100644 --- a/test/integration/vm/vm_for_in_collect_agg_test.go +++ b/test/integration/vm/vm_for_in_collect_agg_test.go @@ -2,8 +2,6 @@ package vm_test import ( "testing" - - . "github.com/MontFerret/ferret/test/integration/base" ) func TestCollectAggregate(t *testing.T) { diff --git a/test/integration/vm/vm_for_in_collect_test.go b/test/integration/vm/vm_for_in_collect_test.go index 14a26a0e..132c7130 100644 --- a/test/integration/vm/vm_for_in_collect_test.go +++ b/test/integration/vm/vm_for_in_collect_test.go @@ -2,8 +2,6 @@ package vm_test import ( "testing" - - . "github.com/MontFerret/ferret/test/integration/base" ) func TestForCollect(t *testing.T) { diff --git a/test/integration/vm/vm_for_in_distinct_test.go b/test/integration/vm/vm_for_in_distinct_test.go index e9113eb2..9d4934d2 100644 --- a/test/integration/vm/vm_for_in_distinct_test.go +++ b/test/integration/vm/vm_for_in_distinct_test.go @@ -2,8 +2,6 @@ package vm_test import ( "testing" - - . "github.com/MontFerret/ferret/test/integration/base" ) func TestForDistinct(t *testing.T) { diff --git a/test/integration/vm/vm_for_in_filter_test.go b/test/integration/vm/vm_for_in_filter_test.go index d27361b1..e0d141ab 100644 --- a/test/integration/vm/vm_for_in_filter_test.go +++ b/test/integration/vm/vm_for_in_filter_test.go @@ -6,7 +6,6 @@ import ( "github.com/MontFerret/ferret/pkg/runtime" "github.com/MontFerret/ferret/pkg/vm" - . "github.com/MontFerret/ferret/test/integration/base" ) func TestForFilter(t *testing.T) { diff --git a/test/integration/vm/vm_for_in_limit_test.go b/test/integration/vm/vm_for_in_limit_test.go index e5390725..520b4813 100644 --- a/test/integration/vm/vm_for_in_limit_test.go +++ b/test/integration/vm/vm_for_in_limit_test.go @@ -6,7 +6,6 @@ import ( "github.com/MontFerret/ferret/pkg/runtime" "github.com/MontFerret/ferret/pkg/vm" - . "github.com/MontFerret/ferret/test/integration/base" ) func TestForLimit(t *testing.T) { diff --git a/test/integration/vm/vm_for_in_nested_test.go b/test/integration/vm/vm_for_in_nested_test.go index 29078f1a..97acc2f1 100644 --- a/test/integration/vm/vm_for_in_nested_test.go +++ b/test/integration/vm/vm_for_in_nested_test.go @@ -2,8 +2,6 @@ package vm_test import ( "testing" - - . "github.com/MontFerret/ferret/test/integration/base" ) func TestForNested(t *testing.T) { diff --git a/test/integration/vm/vm_for_in_sort_test.go b/test/integration/vm/vm_for_in_sort_test.go index c125cdb1..af85f5ee 100644 --- a/test/integration/vm/vm_for_in_sort_test.go +++ b/test/integration/vm/vm_for_in_sort_test.go @@ -6,7 +6,6 @@ import ( "github.com/MontFerret/ferret/pkg/runtime" "github.com/MontFerret/ferret/pkg/vm" - . "github.com/MontFerret/ferret/test/integration/base" ) func TestForSort(t *testing.T) { diff --git a/test/integration/vm/vm_for_in_ternary_test.go b/test/integration/vm/vm_for_in_ternary_test.go index 7be1f145..2819d885 100644 --- a/test/integration/vm/vm_for_in_ternary_test.go +++ b/test/integration/vm/vm_for_in_ternary_test.go @@ -2,8 +2,6 @@ package vm_test import ( "testing" - - . "github.com/MontFerret/ferret/test/integration/base" ) func TestForTernaryExpression(t *testing.T) { diff --git a/test/integration/vm/vm_for_in_test.go b/test/integration/vm/vm_for_in_test.go index 0017c4eb..0087199f 100644 --- a/test/integration/vm/vm_for_in_test.go +++ b/test/integration/vm/vm_for_in_test.go @@ -4,8 +4,6 @@ import ( "context" "testing" - . "github.com/MontFerret/ferret/test/integration/base" - "github.com/MontFerret/ferret/pkg/runtime" "github.com/MontFerret/ferret/pkg/vm" ) diff --git a/test/integration/vm/vm_for_while_filter_test.go b/test/integration/vm/vm_for_while_filter_test.go index c87b8410..802ba508 100644 --- a/test/integration/vm/vm_for_while_filter_test.go +++ b/test/integration/vm/vm_for_while_filter_test.go @@ -4,7 +4,6 @@ import ( "testing" "github.com/MontFerret/ferret/pkg/vm" - . "github.com/MontFerret/ferret/test/integration/base" ) func TestForWhileFilter(t *testing.T) { diff --git a/test/integration/vm/vm_for_while_ternary_test.go b/test/integration/vm/vm_for_while_ternary_test.go index 405097a4..710c6182 100644 --- a/test/integration/vm/vm_for_while_ternary_test.go +++ b/test/integration/vm/vm_for_while_ternary_test.go @@ -3,8 +3,6 @@ package vm_test import ( "testing" - . "github.com/MontFerret/ferret/test/integration/base" - "github.com/MontFerret/ferret/pkg/vm" ) diff --git a/test/integration/vm/vm_for_while_test.go b/test/integration/vm/vm_for_while_test.go index 85333fb6..db49a087 100644 --- a/test/integration/vm/vm_for_while_test.go +++ b/test/integration/vm/vm_for_while_test.go @@ -3,8 +3,6 @@ package vm_test import ( "testing" - . "github.com/MontFerret/ferret/test/integration/base" - "github.com/MontFerret/ferret/pkg/vm" ) diff --git a/test/integration/vm/vm_func_test.go b/test/integration/vm/vm_func_test.go index cefadd39..a6f97508 100644 --- a/test/integration/vm/vm_func_test.go +++ b/test/integration/vm/vm_func_test.go @@ -6,8 +6,6 @@ import ( "github.com/MontFerret/ferret/pkg/runtime" "github.com/MontFerret/ferret/pkg/vm" - - . "github.com/MontFerret/ferret/test/integration/base" ) func TestFunctionCall(t *testing.T) { diff --git a/test/integration/vm/vm_member_test.go b/test/integration/vm/vm_member_test.go index dce8f82c..126e616c 100644 --- a/test/integration/vm/vm_member_test.go +++ b/test/integration/vm/vm_member_test.go @@ -12,7 +12,6 @@ import ( "github.com/MontFerret/ferret/pkg/parser" "github.com/MontFerret/ferret/pkg/runtime" "github.com/MontFerret/ferret/pkg/vm" - . "github.com/MontFerret/ferret/test/integration/base" . "github.com/smartystreets/goconvey/convey" ) diff --git a/test/integration/vm/vm_op_array_test.go b/test/integration/vm/vm_op_array_test.go index 005afb0d..33f7d25d 100644 --- a/test/integration/vm/vm_op_array_test.go +++ b/test/integration/vm/vm_op_array_test.go @@ -2,8 +2,6 @@ package vm_test import ( "testing" - - . "github.com/MontFerret/ferret/test/integration/base" ) func TestArrayAllOperator(t *testing.T) { diff --git a/test/integration/vm/vm_op_equality_test.go b/test/integration/vm/vm_op_equality_test.go index 8f9976d0..e04cdf6a 100644 --- a/test/integration/vm/vm_op_equality_test.go +++ b/test/integration/vm/vm_op_equality_test.go @@ -2,8 +2,6 @@ package vm_test import ( "testing" - - . "github.com/MontFerret/ferret/test/integration/base" ) func TestEqualityOperators(t *testing.T) { diff --git a/test/integration/vm/vm_op_in_test.go b/test/integration/vm/vm_op_in_test.go index fd47597c..6d2761f1 100644 --- a/test/integration/vm/vm_op_in_test.go +++ b/test/integration/vm/vm_op_in_test.go @@ -2,8 +2,6 @@ package vm_test import ( "testing" - - . "github.com/MontFerret/ferret/test/integration/base" ) func TestInOperator(t *testing.T) { diff --git a/test/integration/vm/vm_op_like_test.go b/test/integration/vm/vm_op_like_test.go index fb4aa499..4e826e84 100644 --- a/test/integration/vm/vm_op_like_test.go +++ b/test/integration/vm/vm_op_like_test.go @@ -2,8 +2,6 @@ package vm_test import ( "testing" - - . "github.com/MontFerret/ferret/test/integration/base" ) func TestLikeOperator(t *testing.T) { diff --git a/test/integration/vm/vm_op_logical_test.go b/test/integration/vm/vm_op_logical_test.go index 94dc78f5..98955d39 100644 --- a/test/integration/vm/vm_op_logical_test.go +++ b/test/integration/vm/vm_op_logical_test.go @@ -7,7 +7,6 @@ import ( "github.com/MontFerret/ferret/pkg/runtime" "github.com/MontFerret/ferret/pkg/vm" - . "github.com/MontFerret/ferret/test/integration/base" ) func TestLogicalOperators(t *testing.T) { diff --git a/test/integration/vm/vm_op_math_test.go b/test/integration/vm/vm_op_math_test.go index ca4e05ad..17447515 100644 --- a/test/integration/vm/vm_op_math_test.go +++ b/test/integration/vm/vm_op_math_test.go @@ -2,8 +2,6 @@ package vm_test import ( "testing" - - . "github.com/MontFerret/ferret/test/integration/base" ) func TestMathOperators(t *testing.T) { diff --git a/test/integration/vm/vm_op_regex_test.go b/test/integration/vm/vm_op_regex_test.go index c79562a8..df4bcf19 100644 --- a/test/integration/vm/vm_op_regex_test.go +++ b/test/integration/vm/vm_op_regex_test.go @@ -5,8 +5,6 @@ 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" diff --git a/test/integration/vm/vm_op_ternary_test.go b/test/integration/vm/vm_op_ternary_test.go index a254a94f..42150208 100644 --- a/test/integration/vm/vm_op_ternary_test.go +++ b/test/integration/vm/vm_op_ternary_test.go @@ -6,7 +6,6 @@ import ( . "github.com/smartystreets/goconvey/convey" "github.com/MontFerret/ferret/pkg/compiler" - . "github.com/MontFerret/ferret/test/integration/base" "testing" ) diff --git a/test/integration/vm/vm_op_unary_test.go b/test/integration/vm/vm_op_unary_test.go index ff4553d9..7a821600 100644 --- a/test/integration/vm/vm_op_unary_test.go +++ b/test/integration/vm/vm_op_unary_test.go @@ -5,7 +5,6 @@ import ( "github.com/MontFerret/ferret/pkg/compiler" "github.com/MontFerret/ferret/pkg/vm" - . "github.com/MontFerret/ferret/test/integration/base" gocontext "context" diff --git a/test/integration/vm/vm_param_test.go b/test/integration/vm/vm_param_test.go index a06feac1..5097188c 100644 --- a/test/integration/vm/vm_param_test.go +++ b/test/integration/vm/vm_param_test.go @@ -5,7 +5,6 @@ import ( "github.com/MontFerret/ferret/pkg/runtime" "github.com/MontFerret/ferret/pkg/vm" - . "github.com/MontFerret/ferret/test/integration/base" ) func TestParam(t *testing.T) { diff --git a/test/integration/vm/vm_range_test.go b/test/integration/vm/vm_range_test.go index 1ada5f38..495f6967 100644 --- a/test/integration/vm/vm_range_test.go +++ b/test/integration/vm/vm_range_test.go @@ -5,7 +5,6 @@ import ( "github.com/MontFerret/ferret/pkg/runtime" "github.com/MontFerret/ferret/pkg/vm" - . "github.com/MontFerret/ferret/test/integration/base" ) func TestRange(t *testing.T) { diff --git a/test/integration/vm/vm_string_test.go b/test/integration/vm/vm_string_test.go index 3017822a..207fe009 100644 --- a/test/integration/vm/vm_string_test.go +++ b/test/integration/vm/vm_string_test.go @@ -3,8 +3,6 @@ package vm_test import ( "fmt" "testing" - - . "github.com/MontFerret/ferret/test/integration/base" ) func TestString(t *testing.T) { diff --git a/test/integration/vm/vm_variable_test.go b/test/integration/vm/vm_variable_test.go index 6305a6b3..4d8fffce 100644 --- a/test/integration/vm/vm_variable_test.go +++ b/test/integration/vm/vm_variable_test.go @@ -7,7 +7,6 @@ import ( "github.com/MontFerret/ferret/pkg/compiler" "github.com/MontFerret/ferret/pkg/runtime" "github.com/MontFerret/ferret/pkg/vm" - . "github.com/MontFerret/ferret/test/integration/base" gocontext "context" diff --git a/test/integration/vm/vm_waitfor_event_test.go b/test/integration/vm/vm_waitfor_event_test.go index 99ca7a52..13d7f221 100644 --- a/test/integration/vm/vm_waitfor_event_test.go +++ b/test/integration/vm/vm_waitfor_event_test.go @@ -2,8 +2,6 @@ package vm_test import ( "testing" - - . "github.com/MontFerret/ferret/test/integration/base" ) func TestWaitforEvent(t *testing.T) {