module arrays fn test_min() { a := [8, 2, 6, 4] assert min(a) == 2 assert min(a[2..]) == 4 b := [f32(5.1), 3.1, 1.1, 9.1] assert min(b) == f32(1.1) assert min(b[..2]) == f32(3.1) c := [byte(4), 9, 3, 1] assert min(c) == byte(1) assert min(c[..3]) == byte(3) } fn test_max() { a := [8, 2, 6, 4] assert max(a) == 8 assert max(a[1..]) == 6 b := [f32(5.1), 3.1, 1.1, 9.1] assert max(b) == f32(9.1) assert max(b[..3]) == f32(5.1) c := [byte(4), 9, 3, 1] assert max(c) == byte(9) assert max(c[2..]) == byte(3) } fn test_idx_min() { a := [8, 2, 6, 4] assert idx_min(a) == 1 b := [f32(5.1), 3.1, 1.1, 9.1] assert idx_min(b) == 2 c := [byte(4), 9, 3, 1] assert idx_min(c) == 3 } fn test_idx_max() { a := [8, 2, 6, 4] assert idx_max(a) == 0 b := [f32(5.1), 3.1, 1.1, 9.1] assert idx_max(b) == 3 c := [byte(4), 9, 3, 1] assert idx_max(c) == 1 } fn test_merge() { a := [1, 3, 5, 5, 7] b := [2, 4, 4, 5, 6, 8] c := []int{} d := []int{} assert merge(a, b) == [1, 2, 3, 4, 4, 5, 5, 5, 6, 7, 8] assert merge(c, d) == [] assert merge(a, c) == a assert merge(d, b) == b } fn test_fixed_array_assignment() { mut a := [2]int{} a[0] = 111 a[1] = 222 b := a assert b[0] == a[0] assert b[1] == a[1] mut c := [2]int{} c = a assert c[0] == a[0] assert c[1] == a[1] d := [3]int{init: 333} for val in d { assert val == 333 } e := [3]string{init: 'vlang'} for val in e { assert val == 'vlang' } } fn test_group() { x := [4, 5, 6] y := [2, 1, 3] z := group(x, y) assert z == [[4, 2], [5, 1], [6, 3]] x2 := [8, 9] z2 := group(x2, y) assert z2 == [[8, 2], [9, 1]] assert group(x, []int{}) == [][]int{} }