v2 / vlib / v / tests / fns / call_result_test.v
27 lines · 22 sloc · 343 bytes · 19be2283f0be540b554a465222ed9adf22eb0d19
Raw
1module main
2
3const x = c(c(c('123') or { '456' }) or { '444' }) or { 'xx' }
4
5fn a(s string) ?string {
6 if s == 'b' {
7 return 'a'
8 } else {
9 return none
10 }
11}
12
13fn b(s string) ?string {
14 if s == 'a' {
15 return 'b'
16 } else {
17 return none
18 }
19}
20
21fn c(s string) !string {
22 return a(s) or { b(s) or { 'c' } }
23}
24
25fn test_main() {
26 assert x == 'c'
27}
28