1// package to test types behavior in various conditions (TXs, imports).
2package types
3
4import (
5 "errors"
6 "time"
7
8 "gno.land/p/demo/avl"
9)
10
11var (
12 gInt int = -42
13 gUint uint = 42
14 gString string = "a string"
15 gStringSlice []string = []string{"a", "string", "slice"}
16 gError error = errors.New("an error")
17 gIntSlice []int = []int{-42, 0, 42}
18 gUintSlice []uint = []uint{0, 42, 84}
19 gTree avl.Tree
20 // gInterface = interface{}{-42, "a string", uint(42)}
21)
22
23func init() {
24 gTree.Set("a", "content of A")
25 gTree.Set("b", "content of B")
26}
27
28func Noop() {}
29func RetTimeNow() time.Time { return time.Now() }
30func RetString() string { return gString }
31func RetStringPointer() *string { return &gString }
32func RetUint() uint { return gUint }
33func RetInt() int { return gInt }
34func RetUintPointer() *uint { return &gUint }
35func RetIntPointer() *int { return &gInt }
36func RetTree() avl.Tree { return gTree }
37func RetIntSlice() []int { return gIntSlice }
38func RetUintSlice() []uint { return gUintSlice }
39func RetStringSlice() []string { return gStringSlice }
40func RetError() error { return gError }
41func Panic() { panic("PANIC!") }
42
43// TODO: floats
44// TODO: typed errors
45// TODO: ret interface
46// TODO: recover
47// TODO: take types as input
48
49func Render(path string) string {
50 return "package to test data types."
51}
types.gno
1.45 Kb ยท 51 lines