Skip to content

Commit e437d57

Browse files
committed
Make TestVM_ProfileOperations more robust
1 parent 4ae7e34 commit e437d57

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

vm/vm_test.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"reflect"
77
"strings"
88
"testing"
9+
"time"
910

1011
"github.com/expr-lang/expr/internal/testify/require"
1112

@@ -466,11 +467,16 @@ func TestVM_ProfileOperations(t *testing.T) {
466467
Bytecode: []vm.Opcode{
467468
vm.OpProfileStart,
468469
vm.OpPush,
470+
vm.OpCall,
469471
vm.OpProfileEnd,
470472
},
471-
Arguments: []int{0, 0, 0},
473+
Arguments: []int{0, 1, 0, 0},
472474
Constants: []any{
473475
&vm.Span{},
476+
func() (any, error) {
477+
time.Sleep(time.Millisecond * 10)
478+
return nil, nil
479+
},
474480
},
475481
}
476482

@@ -479,7 +485,7 @@ func TestVM_ProfileOperations(t *testing.T) {
479485
require.NoError(t, err)
480486

481487
span := program.Constants[0].(*vm.Span)
482-
require.True(t, span.Duration > 0, "Profile duration should be greater than 0")
488+
require.Greater(t, span.Duration, time.Millisecond)
483489
}
484490

485491
// TestVM_IndexOperations tests the index manipulation opcodes

0 commit comments

Comments
 (0)