v2 / vlib / v / tests / comptime / comptime_for_alias_methods_test.v
25 lines · 20 sloc · 455 bytes · f3addb5b5095d549dbc7ec0f1847186350e866d7
Raw
1struct App {}
2
3type AliasApp = App
4
5fn (app AliasApp) alias_method() int {
6 return 1
7}
8
9fn (app App) parent_method() int {
10 return 2
11}
12
13fn collect_method_names[T]() []string {
14 mut names := []string{}
15 $for method in T.methods {
16 names << method.name
17 }
18 return names
19}
20
21fn test_comptime_for_alias_methods_includes_alias_and_parent_methods() {
22 names := collect_method_names[AliasApp]()
23 assert 'alias_method' in names
24 assert 'parent_method' in names
25}
26