tests: enable test_generic_fn_with_variadics() test (#9944)
parent
605019ec27
commit
f82f1977d1
|
@ -345,13 +345,16 @@ fn test_generic_struct_print_array_as_field() {
|
||||||
assert foo.str() == 'Foo<[]string>{\n data: []\n}'
|
assert foo.str() == 'Foo<[]string>{\n data: []\n}'
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
struct Abc {
|
||||||
struct Abc{ x int y int z int }
|
x int
|
||||||
|
y int
|
||||||
|
z int
|
||||||
|
}
|
||||||
|
|
||||||
fn p<T>(args ...T) {
|
fn p<T>(args ...T) {
|
||||||
size:=sizeof(T)
|
size := sizeof(T)
|
||||||
print('p called with size: ${size:3d} | ')
|
print('p called with size: ${size:3} | ')
|
||||||
for _,x in args {
|
for _, x in args {
|
||||||
print(x)
|
print(x)
|
||||||
print(' ')
|
print(' ')
|
||||||
}
|
}
|
||||||
|
@ -359,10 +362,10 @@ fn p<T>(args ...T) {
|
||||||
assert true
|
assert true
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_generic_fn_with_variadics(){
|
fn test_generic_fn_with_variadics() {
|
||||||
s:='abc'
|
s := 'abc'
|
||||||
i:=1
|
i := 1
|
||||||
abc:=Abc{1,2,3}
|
abc := Abc{1, 2, 3}
|
||||||
// these calls should all compile, and print the arguments,
|
// these calls should all compile, and print the arguments,
|
||||||
// even though the arguments are all a different type and arity:
|
// even though the arguments are all a different type and arity:
|
||||||
p(s)
|
p(s)
|
||||||
|
@ -370,7 +373,6 @@ fn test_generic_fn_with_variadics(){
|
||||||
p(abc)
|
p(abc)
|
||||||
p('Good', 'morning', 'world')
|
p('Good', 'morning', 'world')
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
struct Context {}
|
struct Context {}
|
||||||
|
|
||||||
|
@ -392,24 +394,6 @@ fn test_pass_generic_to_nested_function() {
|
||||||
test(mut app)
|
test(mut app)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
struct NestedGeneric {}
|
|
||||||
|
|
||||||
fn (ng NestedGeneric) nested_test<T>(mut app T) {
|
|
||||||
app.context = Context {}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn method_test<T>(mut app T) {
|
|
||||||
ng := NestedGeneric{}
|
|
||||||
ng.nested_test<T>(app)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn test_pass_generic_to_nested_method() {
|
|
||||||
mut app := App{}
|
|
||||||
method_test(mut app)
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
fn generic_return_map<M>() map[string]M {
|
fn generic_return_map<M>() map[string]M {
|
||||||
return map{
|
return map{
|
||||||
'': M{}
|
'': M{}
|
||||||
|
|
Loading…
Reference in New Issue