v2 / vlib / v / tests / interfaces / interface_arr_auto_str_test.v
25 lines · 21 sloc · 325 bytes · 7af8fafc18db21c6995b776ed2404a9febe09c52
Raw
1interface Interface {
2 str() string
3}
4
5struct Result[T] {
6 data []T
7}
8
9struct Foobar {
10}
11
12fn (f Foobar) str() string {
13 return 'foobar'
14}
15
16fn test_main() {
17 assert Result[Interface]{}.str() == 'Result[Interface]{
18 data: []
19}'
20 assert Result[Foobar]{
21 data: [Foobar{}]
22 }.str() == 'Result[Foobar]{
23 data: [foobar]
24}'
25}
26