Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Methods defined on _test.gno files are not recognised on test files #2888

Open
Villaquiranm opened this issue Oct 2, 2024 · 0 comments
Open

Comments

@Villaquiranm
Copy link
Contributor

Villaquiranm commented Oct 2, 2024

Methods defined on _test.gno files are not recognised on test files

Description

Found this while porting the strings.Replacer on standard lib 'strings' #2816
specifically on stdlibs/strings/export_test.gno.
there we define PrintTrie function func (r *Replacer) PrintTrie() string {

Your environment

  • Gno commit hash causing the issue : lastest

Steps to reproduce

  • Tell us how to reproduce this issue
  • Where the issue is, if you know
  • Which commands triggered the issue, if any

Expected behaviour

On Go you can define exported Methods to use on the test as for example they do on standard library strings with PrintTrie function. This allows developers to use said function on the test without exporting the method on the non-test context.

Actual behaviour

Currently on Gno the method is not recognized on both test and non-test contexts.

Logs

On Go

// export_test.go
package gotest

func (d *Doer) DoSomething() string {
	return "hello world!"
}
// doer.go
package gotest

type Doer struct {
}

func NewDoer() *Doer {
	return &Doer{}
}
package gotest_test

import (
	"testing"
)

func TestDoer(t *testing.T) {
	gotest.NewDoer().DoSomething()
}

will output ok github.com/gnolang/gno/gotest 0.512s

While on Gno the same setup will output
; panic: strings_test/testfunc_test.gno:9:2: missing field DoSomething in *strings.Doer:
plus more stacktrace

Tested on std libs

Proposed solution

If you have an idea of how to fix this issue, please write it down here, so we can begin discussing it

@Villaquiranm Villaquiranm changed the title Methods defined on _test.gno filed are not recognised on test files Methods defined on _test.gno files are not recognised on test files Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Triage
Development

No branches or pull requests

1 participant