v2 / vlib / v / tests / comptime / comptime_dump_test.v
48 lines · 42 sloc · 574 bytes · 6488041a749df9762348d019c4223908c476f2e2
Raw
1@[abc]
2struct Another {
3 a []int
4 b u8
5 c u32
6}
7
8fn (f Another) test() {}
9
10enum Abc {
11 a
12 b
13 c
14}
15
16fn test_main() {
17 mut c := 0
18 $for f in Abc.values {
19 dump(f)
20 dump(f.value)
21 c += 1
22 assert typeof(f).name == 'EnumData'
23 }
24 assert c == 3
25
26 $for f in Another.fields {
27 dump(f)
28 dump(f.name)
29 c += 1
30 }
31 assert c == 6
32
33 $for f in Another.methods {
34 dump(f)
35 dump(f.name)
36 c += 1
37 assert typeof(f).name == 'FunctionData'
38 }
39 assert c == 7
40
41 $for f in Another.attributes {
42 dump(f)
43 dump(f.name)
44 c += 1
45 assert typeof(f).name == 'VAttribute'
46 }
47 assert c == 8
48}
49