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