v2 / vlib / v / tests / generics / generics_with_nested_generics_fn_test.v
27 lines · 22 sloc · 395 bytes · 6488041a749df9762348d019c4223908c476f2e2
Raw
1struct NestedGeneric {
2}
3
4struct Context {
5}
6
7struct App {
8mut:
9 context Context
10}
11
12fn (ng NestedGeneric) nested_test[T](mut app T) {
13 app.context = Context{}
14}
15
16fn method_test[T](mut app T) int {
17 ng := NestedGeneric{}
18 ng.nested_test[T](mut app)
19 return 22
20}
21
22fn test_generics_with_generics_fn() {
23 mut app := App{}
24 ret := method_test(mut app)
25 println('result = ${ret}')
26 assert ret == 22
27}
28