-
Notifications
You must be signed in to change notification settings - Fork 385
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add tests_foo cross-realm type storage test
- Loading branch information
Showing
3 changed files
with
823 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package tests | ||
|
||
import ( | ||
"strconv" | ||
) | ||
|
||
type Stringer interface { | ||
String() string | ||
} | ||
|
||
var stringers []Stringer | ||
|
||
func AddStringer(str Stringer) { | ||
// NOTE: this is ridiculous, a slice that will become too long | ||
// eventually. Don't do this in production programs; use | ||
// gno.land/p/avl or similar structures. | ||
stringers = append(stringers, str) | ||
} | ||
|
||
func Render(path string) string { | ||
res := "" | ||
// NOTE: like the function above, this function too will eventually | ||
// become too expensive to call. | ||
for i, stringer := range stringers { | ||
res += strconv.Itoa(i) + ": " + stringer.String() + "\n" | ||
} | ||
return res | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package tests_foo | ||
|
||
import ( | ||
"gno.land/r/tests" | ||
) | ||
|
||
// for testing gno.land/r/tests/interfaces.go | ||
|
||
type FooStringer struct { | ||
FieldA string | ||
} | ||
|
||
func (fs *FooStringer) String() string { | ||
return "&FooStringer{" + fs.FieldA + "}" | ||
} | ||
|
||
func AddFooStringer(fa string) { | ||
tests.AddStringer(&FooStringer{fa}) | ||
} |
Oops, something went wrong.