v2 / vlib / v / tests / comptime / comptime_var_param_test.v
26 lines · 21 sloc · 298 bytes · b0ea31e90d145fead68fc62625b5b40c060937f3
Raw
1struct Aa {
2 sub AliasType
3}
4
5type AliasType = Bb
6
7struct Bb {
8 a int
9}
10
11fn encode_struct[U](val U) string {
12 $for field in U.fields {
13 encode_struct(val.$(field.name))
14 }
15 return val.str()
16}
17
18fn test_main() {
19 aa := Aa{}
20
21 assert encode_struct(aa) == 'Aa{
22 sub: AliasType(Bb{
23 a: 0
24})
25}'
26}
27