tests: update generics_method_str_overload_test.v to return a generic type, instead of `Gen<G>`. (#12465)

pull/12473/head weekly.2021.46
Charles WANG 2021-11-15 21:36:54 +08:00 committed by GitHub
parent cbdb270d2f
commit 1d003228cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 5 deletions

View File

@ -5,23 +5,23 @@ struct Gen<G> {
} }
fn (g Gen<G>) str() string { fn (g Gen<G>) str() string {
return 'Gen<G> $g.id, $g.data, ${g.size}.' return 'Gen<$G.name>{$g.id, $g.data, $g.size}'
} }
fn test_generics_method_str_overload() { fn test_generics_method_str_overload() {
mut g1 := Gen<string>{'aaa', 0, 10} mut g1 := Gen<string>{'aaa', 0, 10}
println(g1) println(g1)
assert '$g1' == 'Gen<G> 0, aaa, 10.' assert '$g1' == 'Gen<string>{0, aaa, 10}'
mut g2 := Gen<int>{22, 0, 10} mut g2 := Gen<int>{22, 0, 10}
println(g2) println(g2)
assert '$g2' == 'Gen<G> 0, 22, 10.' assert '$g2' == 'Gen<int>{0, 22, 10}'
mut g3 := Gen<f64>{2.22, 0, 10} mut g3 := Gen<f64>{2.22, 0, 10}
println(g3) println(g3)
assert '$g3' == 'Gen<G> 0, 2.22, 10.' assert '$g3' == 'Gen<f64>{0, 2.22, 10}'
mut g4 := Gen<bool>{true, 0, 10} mut g4 := Gen<bool>{true, 0, 10}
println(g4) println(g4)
assert '$g4' == 'Gen<G> 0, true, 10.' assert '$g4' == 'Gen<bool>{0, true, 10}'
} }