z0_filetest.gno
0.79 Kb ยท 28 lines
1package main
2
3import (
4 "gno.land/r/demo/tests"
5)
6
7func main() {
8 println("tests.CallIsOriginCall:", tests.CallIsOriginCall())
9 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:", tests.CallIsOriginCall())
16 defer func() {
17 r := recover()
18 println("tests.AssertOriginCall panics if when called inside a function literal:", r)
19 }()
20 tests.CallAssertOriginCall()
21 }
22}
23
24// Output:
25// tests.CallIsOriginCall: true
26// tests.CallAssertOriginCall doesn't panic when called directly
27// tests.CallIsOriginCall: true
28// tests.AssertOriginCall panics if when called inside a function literal: undefined