v2 / vlib / v / tests / interfaces / interface_auto_str_test.v
31 lines · 25 sloc · 405 bytes · 6488041a749df9762348d019c4223908c476f2e2
Raw
1interface Context {
2 str() string
3}
4
5struct OtherContext {
6 a string
7}
8
9pub fn (o &OtherContext) str() string {
10 return 'OtherContext'
11}
12
13struct WithContext {
14pub mut:
15 ctx Context
16}
17
18fn with_function(ctx Context) {
19 println(ctx)
20}
21
22fn test_main() {
23 mut s := WithContext{
24 ctx: OtherContext{}
25 }
26 assert dump(s) == WithContext{
27 ctx: OtherContext{}
28 }
29
30 assert dump(OtherContext{}) == OtherContext{}
31}
32