From ebbf42dadb6af901ffd7ea72a0e19bda7a987b3a Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Wed, 27 May 2020 08:41:03 +0300 Subject: [PATCH] tests: add a commented test_generic_fn_with_variadics, which worked with old v --- vlib/v/tests/generics_test.v | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/vlib/v/tests/generics_test.v b/vlib/v/tests/generics_test.v index 1e369c6cbe..0920e107e4 100644 --- a/vlib/v/tests/generics_test.v +++ b/vlib/v/tests/generics_test.v @@ -169,4 +169,32 @@ fn test_generic_struct() { assert a.model.name == 'joe' assert b.model.name == 'joe' } + +// + +struct Abc{ x int y int z int } + +fn p(args ...T) { + size:=sizeof(T) + print('p called with size: ${size:3d} | ') + for _,x in args { + print(x) + print(' ') + } + println('') + assert true +} + +fn test_generic_fn_with_variadics(){ + s:='abc' + i:=1 + abc:=Abc{1,2,3} + // these calls should all compile, and print the arguments, + // even though the arguments are all a different type and arity: + p(s) + p(i) + p(abc) + p('Good','morning','world') +} + */