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