Skip to content

Commit

Permalink
Add testing util CheckScopeVar` (#308)
Browse files Browse the repository at this point in the history
  • Loading branch information
fmoletta authored Oct 2, 2023
1 parent 78c0a08 commit 9cde79b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions pkg/hints/hint_utils/testing_utils.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package hint_utils

import (
"reflect"
"testing"

"github.com/lambdaclass/cairo-vm.go/pkg/lambdaworks"
"github.com/lambdaclass/cairo-vm.go/pkg/parser"
"github.com/lambdaclass/cairo-vm.go/pkg/types"
. "github.com/lambdaclass/cairo-vm.go/pkg/vm"
"github.com/lambdaclass/cairo-vm.go/pkg/vm/memory"
)
Expand Down Expand Up @@ -56,3 +60,13 @@ func SetupConstantsForTest(new_constants map[string]lambdaworks.Felt, ids *IdsMa
}
return constants
}

func CheckScopeVar[T any](name string, expectedVal T, scopes *types.ExecutionScopes, t *testing.T) {
val, err := types.FetchScopeVar[T](name, scopes)
if err != nil {
t.Error(err.Error())
}
if !reflect.DeepEqual(val, expectedVal) {
t.Errorf("Wrong scope var %s.\n Expected: %v, got: %v", name, expectedVal, val)
}
}

0 comments on commit 9cde79b

Please sign in to comment.