diff options
Diffstat (limited to 'v_windows/v/old/vlib/v/tests/generic_fn_infer_struct_test.v')
-rw-r--r-- | v_windows/v/old/vlib/v/tests/generic_fn_infer_struct_test.v | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/v_windows/v/old/vlib/v/tests/generic_fn_infer_struct_test.v b/v_windows/v/old/vlib/v/tests/generic_fn_infer_struct_test.v new file mode 100644 index 0000000..3985e1e --- /dev/null +++ b/v_windows/v/old/vlib/v/tests/generic_fn_infer_struct_test.v @@ -0,0 +1,19 @@ +struct Node<T> { + data T +} + +fn foo<T>(n Node<T>) string { + return '$n' +} + +fn test_generics_fn_infer_struct() { + ret1 := foo(Node<int>{}) + println(ret1) + assert ret1.contains('Node<int>{') + assert ret1.contains('data: 0') + + ret2 := foo(Node<byte>{}) + println(ret2) + assert ret2.contains('Node<byte>{') + assert ret2.contains('data: 0') +} |