v2 / vlib / v / tests / arrays_closure_fixed_array_test.v
17 lines · 14 sloc · 392 bytes · a388b3be843783297b04171b05ba33faa85eb687
Raw
1import arrays
2
3fn test_main() {
4 mut rules := [][2]int{}
5 rules << [1, 2]!
6 rules << [2, 3]!
7
8 common_rule := [1, 2]!
9 assert arrays.index_of_first(rules, fn [common_rule] (idx int, rule [2]int) bool {
10 return rule == common_rule
11 }) == 0
12
13 common_rule2 := [2, 3]!
14 assert arrays.index_of_first(rules, fn [common_rule2] (idx int, rule [2]int) bool {
15 return rule == common_rule2
16 }) == 1
17}
18