github.com/gnolang/gno@v0.0.0-20240520182011-228e9d0192ce/gnovm/tests/files/zrealm_crossrealm12.gno (about)

     1  // PKGPATH: gno.land/r/crossrealm_test
     2  package crossrealm_test
     3  
     4  import (
     5  	"std"
     6  	"fmt"
     7  
     8  	psubtests "gno.land/p/demo/tests/subtests"
     9  	rsubtests "gno.land/r/demo/tests/subtests"
    10  )
    11  
    12  func main() {
    13  	tests := []struct{
    14  		fn func() std.Realm
    15  	}{
    16  		{ std.CurrentRealm },
    17  		{ psubtests.GetCurrentRealm },
    18  		{ rsubtests.GetCurrentRealm },
    19  	}
    20  	
    21  	for _, test := range tests {
    22  		r := test.fn()
    23  
    24  		if std.DerivePkgAddr(r.PkgPath()) != r.Addr() {
    25  			panic(fmt.Sprintf("ERROR: expected: %v, got: %v",
    26  				std.DerivePkgAddr(r.PkgPath()), r.Addr(),
    27  			))
    28  		}
    29  
    30  		println(r.PkgPath(), r.Addr())
    31  	}
    32  }
    33  
    34  // Output:
    35  // gno.land/r/crossrealm_test g1vla5mffzum6060t99u4xhm8mnhgxr0sz4k574p
    36  // gno.land/r/crossrealm_test g1vla5mffzum6060t99u4xhm8mnhgxr0sz4k574p
    37  // gno.land/r/demo/tests/subtests g13g48xnr7lzxsrvny0uf6lhx0cfaxy4n0n5geuf