v2 / vlib / v / tests / pointers / vargs_reference_param_test.v
27 lines · 21 sloc · 422 bytes · 6488041a749df9762348d019c4223908c476f2e2
Raw
1@[heap]
2struct Foo {
3 name string
4}
5
6fn agg_stuff(stuffs ...&Foo) []&Foo {
7 stuffs2 := stuffs.clone()
8 return stuffs2
9}
10
11fn arr_stuff(stuffs []&Foo) []&Foo {
12 stuffs2 := stuffs.clone()
13 return stuffs2
14}
15
16fn test_vargs_with_reference_params() {
17 foo1 := &Foo{'foo'}
18 foo2 := &Foo{'bar'}
19
20 foo11 := agg_stuff(foo1, foo2)
21 println(foo11)
22
23 foo22 := arr_stuff([foo1, foo2])
24 println(foo22)
25
26 assert '${foo11}' == '${foo22}'
27}
28