From f82f1977d1701189575b58bc90de3f8dd4072754 Mon Sep 17 00:00:00 2001 From: yuyi Date: Sat, 1 May 2021 17:52:47 +0800 Subject: [PATCH] tests: enable test_generic_fn_with_variadics() test (#9944) --- vlib/v/tests/generics_test.v | 40 +++++++++++------------------------- 1 file changed, 12 insertions(+), 28 deletions(-) diff --git a/vlib/v/tests/generics_test.v b/vlib/v/tests/generics_test.v index 36baa2d533..580f27abd8 100644 --- a/vlib/v/tests/generics_test.v +++ b/vlib/v/tests/generics_test.v @@ -345,13 +345,16 @@ fn test_generic_struct_print_array_as_field() { assert foo.str() == 'Foo<[]string>{\n data: []\n}' } -/* -struct Abc{ x int y int z int } +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 { + size := sizeof(T) + print('p called with size: ${size:3} | ') + for _, x in args { print(x) print(' ') } @@ -359,10 +362,10 @@ fn p(args ...T) { assert true } -fn test_generic_fn_with_variadics(){ - s:='abc' - i:=1 - abc:=Abc{1,2,3} +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) @@ -370,7 +373,6 @@ fn test_generic_fn_with_variadics(){ p(abc) p('Good', 'morning', 'world') } -*/ struct Context {} @@ -392,24 +394,6 @@ fn test_pass_generic_to_nested_function() { test(mut app) } -/* -struct NestedGeneric {} - -fn (ng NestedGeneric) nested_test(mut app T) { - app.context = Context {} -} - -fn method_test(mut app T) { - ng := NestedGeneric{} - ng.nested_test(app) -} - -fn test_pass_generic_to_nested_method() { - mut app := App{} - method_test(mut app) -} -*/ - fn generic_return_map() map[string]M { return map{ '': M{}