Fix tests

This commit is contained in:
Anton Medvedev
2024-02-17 11:15:54 +01:00
parent 2af0e981b2
commit 129e6b3669
2 changed files with 7 additions and 6 deletions
+4 -3
View File
@@ -3,6 +3,7 @@ package checker_test
import (
"reflect"
"testing"
"time"
"github.com/stretchr/testify/require"
@@ -11,12 +12,12 @@ import (
)
func TestTypedFuncIndex(t *testing.T) {
fn := func([]any, string) string {
return "foo"
fn := func() time.Duration {
return 1 * time.Second
}
index, ok := checker.TypedFuncIndex(reflect.TypeOf(fn), false)
require.True(t, ok)
require.Equal(t, 22, index)
require.Equal(t, 1, index)
}
func TestTypedFuncIndex_excludes_named_functions(t *testing.T) {
+3 -3
View File
@@ -319,7 +319,7 @@ func TestCompile(t *testing.T) {
vm.OpMethod,
vm.OpCallTyped,
},
Arguments: []int{0, 0, 1, 10},
Arguments: []int{0, 0, 1, 12},
},
},
}
@@ -358,7 +358,7 @@ func TestCompile_FuncTypes(t *testing.T) {
program, err := expr.Compile("fn([1, 2], 'bar')", expr.Env(env))
require.NoError(t, err)
require.Equal(t, vm.OpCallTyped, program.Bytecode[3])
require.Equal(t, 22, program.Arguments[3])
require.Equal(t, 32, program.Arguments[3])
}
func TestCompile_FuncTypes_with_Method(t *testing.T) {
@@ -366,7 +366,7 @@ func TestCompile_FuncTypes_with_Method(t *testing.T) {
program, err := expr.Compile("FuncTyped('bar')", expr.Env(env))
require.NoError(t, err)
require.Equal(t, vm.OpCallTyped, program.Bytecode[2])
require.Equal(t, 42, program.Arguments[2])
require.Equal(t, 76, program.Arguments[2])
}
func TestCompile_FuncTypes_excludes_named_functions(t *testing.T) {