| 1 | fn test_fixed_array_lit_init() { |
| 2 | a1 := ['1', '2', '3']! |
| 3 | assert typeof(a1).name == '[3]string' |
| 4 | assert '${a1}' == "['1', '2', '3']" |
| 5 | a2 := ['a', 'b']! |
| 6 | assert typeof(a2).name == '[2]string' |
| 7 | assert '${a2}' == "['a', 'b']" |
| 8 | c1 := [1, 2, 3]! |
| 9 | assert typeof(c1).name == '[3]int' |
| 10 | assert '${c1}' == '[1, 2, 3]' |
| 11 | c2 := [i16(1), 2, 3]! |
| 12 | assert typeof(c2).name == '[3]i16' |
| 13 | assert '${c2}' == '[1, 2, 3]' |
| 14 | mut c3 := [i64(1), 2, 3]! |
| 15 | assert typeof(c3).name == '[3]i64' |
| 16 | assert '${c3}' == '[1, 2, 3]' |
| 17 | mut c4 := [u64(1), 2, 3]! |
| 18 | assert typeof(c4).name == '[3]u64' |
| 19 | assert '${c4}' == '[1, 2, 3]' |
| 20 | mut d1 := [1.1, 2.2, 3.3]! |
| 21 | assert typeof(d1).name == '[3]f64' |
| 22 | assert '${d1}' == '[1.1, 2.2, 3.3]' |
| 23 | mut d2 := [f32(1.1), 2.2, 3.3]! |
| 24 | assert typeof(d2).name == '[3]f32' |
| 25 | assert '${d2}' == '[1.1, 2.2, 3.3]' |
| 26 | } |
| 27 | |
| 28 | fn test_fixed_type_init() { |
| 29 | a := [2]int{} |
| 30 | assert a == [2]int{} |
| 31 | assert a == [0, 0]! |
| 32 | assert a == a |
| 33 | mut c := [3, 3]! |
| 34 | assert a != c |
| 35 | assert c == [3, 3]! |
| 36 | c = [2]int{} |
| 37 | assert a == c |
| 38 | } |
| 39 | |
| 40 | fn test_fixed_custom_init() { |
| 41 | a := [2]u8{init: 7} |
| 42 | assert a == [u8(7), 7]! |
| 43 | mut b := [3]int{} |
| 44 | assert b == [0, 0, 0]! |
| 45 | // assign |
| 46 | b = [3]int{init: 5} |
| 47 | assert b == [5, 5, 5]! |
| 48 | } |
| 49 | |