v2 / vlib / v / tests / fns / anon_fn_with_array_arguments_test.v
24 lines · 19 sloc · 403 bytes · 6488041a749df9762348d019c4223908c476f2e2
Raw
1struct Test {
2 fn_test fn (x int, y [10]int, z []int) bool = fixed_array_fn
3}
4
5fn fixed_array_fn(x int, y [10]int, z []int) bool {
6 return true
7}
8
9fn test_anon_fn_with_fixed_array_arguments() {
10 assert true
11}
12
13fn fn_arg(f fn ([]int) int) int {
14 return f([1, 2, 3])
15}
16
17fn test_anon_fn_with_array_arguments() {
18 anon := fn (i []int) int {
19 return 0
20 }
21
22 println(fn_arg(anon))
23 assert fn_arg(anon) == 0
24}
25