| 1 | struct Foo {} |
| 2 | |
| 3 | type Bar = [4]Foo |
| 4 | |
| 5 | struct Baz { |
| 6 | data int |
| 7 | } |
| 8 | |
| 9 | type BazFixed = [2]Baz |
| 10 | type NestedBazFixed = [2]BazFixed |
| 11 | |
| 12 | struct Empty {} |
| 13 | |
| 14 | type EmptyFixed = [2]Empty |
| 15 | |
| 16 | type Dot = [3]f64 |
| 17 | type Box = [2]Dot |
| 18 | |
| 19 | struct Tst { |
| 20 | box Box |
| 21 | val int |
| 22 | } |
| 23 | |
| 24 | fn test_alias_fixed_array_of_struct() { |
| 25 | bar := Bar([Foo{}, Foo{}, Foo{}, Foo{}]!) |
| 26 | println(bar) |
| 27 | assert '${bar}' == 'Bar([Foo{}, Foo{}, Foo{}, Foo{}])' |
| 28 | } |
| 29 | |
| 30 | fn test_nested_fixed_array_alias_of_named_struct() { |
| 31 | nested := [2]NestedBazFixed{} |
| 32 | assert nested.len == 2 |
| 33 | assert nested[0].len == 2 |
| 34 | assert nested[0][0][0].data == 0 |
| 35 | } |
| 36 | |
| 37 | fn test_fixed_array_alias_of_empty_struct() { |
| 38 | nested := [2]EmptyFixed{} |
| 39 | assert nested.len == 2 |
| 40 | assert nested[0].len == 2 |
| 41 | } |
| 42 | |
| 43 | fn test_nested_fixed_array_alias_in_struct_init() { |
| 44 | v_box := Box{} |
| 45 | assert v_box.len == 2 |
| 46 | assert v_box[0].len == 3 |
| 47 | |
| 48 | v_tst := Tst{Box([2]Dot{}), 1} |
| 49 | println(v_tst) |
| 50 | assert v_tst.val == 1 |
| 51 | assert v_tst.box[0][0] == 0.0 |
| 52 | assert v_tst.box[1][2] == 0.0 |
| 53 | } |
| 54 | |