v2 / vlib / v / tests / autofree_result_method_chain_test.v
28 lines · 22 sloc · 528 bytes · 3324dd3bb8f90b56666e99538b68e1da7369057f
Raw
1// vtest vflags: -autofree
2// vtest build: !sanitize-address-gcc && !sanitize-address-clang
3
4fn get_str_a() ?string {
5 return 'hello world?'
6}
7
8fn process_a(s string) string {
9 return s.to_upper()
10}
11
12fn get_str_b() !string {
13 return 'hello world!'
14}
15
16fn process_b(s string) string {
17 return s.to_upper()
18}
19
20fn test_autofree_chain_a() {
21 result := process_a(get_str_a()?.to_upper())
22 assert result == 'HELLO WORLD?'
23}
24
25fn test_autofree_chain_b() {
26 result := process_b(get_str_b()!.to_upper())
27 assert result == 'HELLO WORLD!'
28}
29