v2 / vlib / v / tests / loops / for_in_alias_test.v
26 lines · 22 sloc · 412 bytes · 6488041a749df9762348d019c4223908c476f2e2
Raw
1enum Nucleotide {
2 a
3 c
4 g
5 t
6}
7
8type Codon = []Nucleotide
9type Gene = []Codon
10
11fn test_for_in_alias() {
12 mut gene := Gene([
13 Codon([Nucleotide.a, Nucleotide.c, Nucleotide.g]),
14 Codon([Nucleotide.g, Nucleotide.a, Nucleotide.t]),
15 ])
16
17 mut ret := []string{}
18 for cdn in gene {
19 println(cdn)
20 ret << '${cdn}'
21 }
22
23 assert ret.len == 2
24 assert ret[0] == 'Codon([a, c, g])'
25 assert ret[1] == 'Codon([g, a, t])'
26}
27