z0_filetest.gno
0.82 Kb ยท 28 lines
1package main
2
3import (
4 "gno.land/r/demo/tests"
5)
6
7func main() {
8 println("tests.CallIsOriginCall:", cross(tests.CallIsOriginCall)())
9 cross(tests.CallAssertOriginCall)()
10 println("tests.CallAssertOriginCall doesn't panic when called directly")
11
12 {
13 // if called inside a block, this is no longer an origin call because
14 // there's one additional frame (the block).
15 println("tests.CallIsOriginCall:", cross(tests.CallIsOriginCall)())
16 defer func() {
17 r := recover()
18 println("tests.AssertOriginCall panics if when called inside a function literal:", r)
19 }()
20 cross(tests.CallAssertOriginCall)()
21 }
22}
23
24// Output:
25// tests.CallIsOriginCall: false
26// tests.CallAssertOriginCall doesn't panic when called directly
27// tests.CallIsOriginCall: false
28// tests.AssertOriginCall panics if when called inside a function literal: undefined