v2 / vlib / v / tests / printing / dump_option_interface_string_interpolation_test.v
31 lines · 25 sloc · 481 bytes · 30cb3213c0df43f70a43f697996d13fcddc6b0d2
Raw
1interface Nested {
2 str() string
3}
4
5struct Leaf {
6 name string
7}
8
9fn (l Leaf) str() string {
10 return l.name
11}
12
13fn denest_none() ?Nested {
14 return none
15}
16
17fn denest_value() ?Nested {
18 return Leaf{'leaf'}
19}
20
21fn test_dump_string_interpolation_of_option_interface_none() {
22 n := denest_none()
23 s := dump('${n}')
24 assert s == 'Option(none)'
25}
26
27fn test_dump_string_interpolation_of_option_interface_value() {
28 n := denest_value()
29 s := dump('${n}')
30 assert s == 'Option(Nested(leaf))'
31}
32