Skip to content

Commit

Permalink
solve comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Your Name committed Mar 10, 2025
1 parent a09f23a commit f8f6cf5
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 53 deletions.
7 changes: 0 additions & 7 deletions examples/no_cycles_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ import (
"github.com/stretchr/testify/require"
)

// XXX: move this into `gno lint`

var injectedTestingLibs = []string{"encoding/json", "fmt", "os"}

// TestNoCycles checks that there is no import cycles in stdlibs and non-draft examples
func TestNoCycles(t *testing.T) {
// find stdlibs
Expand Down Expand Up @@ -101,9 +97,6 @@ func detectCycles(root testPkg, pkgs []testPkg, visited map[string]bool) error {
// visitImports resolves and visits imports by kinds
func visitImports(kinds []packages.FileKind, root testPkg, pkgs []testPkg, visited map[string]bool, stack []string) error {
for _, imp := range root.Imports.Merge(kinds...) {
if slices.Contains(injectedTestingLibs, imp.PkgPath) {
continue
}
idx := slices.IndexFunc(pkgs, func(p testPkg) bool { return p.PkgPath == imp.PkgPath })
if idx == -1 {
return fmt.Errorf("import %q not found for %q tests", imp.PkgPath, root.PkgPath)
Expand Down
3 changes: 1 addition & 2 deletions gnovm/pkg/gnolang/preprocess.go
Original file line number Diff line number Diff line change
Expand Up @@ -1284,10 +1284,9 @@ func preprocess1(store Store, ctx BlockNode, n Node) Node {
atBase := baseOf(at)

_, isCTInterface := ctBase.(*InterfaceType)
_, isCTNative := ctBase.(*NativeType)
_, isATInterface := atBase.(*InterfaceType)

if (!isCTInterface && !isCTNative) && isATInterface {
if !isCTInterface && isATInterface {
panic(fmt.Sprintf("cannot convert %v to %v: need type assertion", at.TypeID(), ct.TypeID()))
}
}
Expand Down
5 changes: 3 additions & 2 deletions gnovm/stdlibs/testing/match.gno
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ func (m simpleMatch) verify(name string) error {
}
// Verify filters before doing any processing.
for i, s := range m {
if !verifyRegex(s) {
return fmt.Errorf("element %d of %s (%q)", i, name, s)
err := verifyRegex(s)
if err != "" {
return fmt.Errorf("element %d of %s (%q): %s", i, name, s, err)
}
}
return nil
Expand Down
38 changes: 0 additions & 38 deletions gnovm/tests/files/xfactor_long.gno

This file was deleted.

2 changes: 1 addition & 1 deletion gnovm/tests/stdlibs/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion gnovm/tests/stdlibs/testing/native_testing.gno
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ func unixNano() int64

func matchString(pat, str string) bool

func verifyRegex(pat string) (ok bool)
func verifyRegex(pat string) string

func recoverWithStacktrace() (interface{}, string)
7 changes: 5 additions & 2 deletions gnovm/tests/stdlibs/testing/native_testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@ func X_matchString(pat, str string) bool {
return matchRe.MatchString(str)
}

func X_verifyRegex(pat string) (ok bool) {
func X_verifyRegex(pat string) string {
_, err := regexp.Compile(pat)
return err == nil
if err != nil {
return err.Error()
}
return ""
}

func X_recoverWithStacktrace(m *gnolang.Machine) (gnolang.TypedValue, string) {
Expand Down

0 comments on commit f8f6cf5

Please sign in to comment.