v2 / vlib / v / tests / structs / struct_field_fn_call_test.v
18 lines · 15 sloc · 225 bytes · e2e5cf8db56f3562c7baa735061690be936bdf3e
Raw
1struct Foo {
2 f fn (main.Foo) int = dummy
3}
4
5fn dummy(s Foo) int {
6 return 22
7}
8
9fn (mut s Foo) fun() int {
10 return s.f(s)
11}
12
13fn test_struct_field_fn_call() {
14 mut s := Foo{}
15 ret := s.fun()
16 println(ret)
17 assert ret == 22
18}
19