Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
antonmedv committed Feb 17, 2024
1 parent ed89647 commit 1719809
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 deletions checker/info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package checker_test
import (
"reflect"
"testing"
"time"

"github.com/stretchr/testify/require"

Expand All @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions compiler/compiler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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},
},
},
}
Expand Down Expand Up @@ -358,15 +358,15 @@ 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) {
env := mock.Env{}
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) {
Expand Down

0 comments on commit 1719809

Please sign in to comment.