| 1 | struct Holder { |
| 2 | mut: |
| 3 | err ?IError |
| 4 | } |
| 5 | |
| 6 | fn (mut h Holder) set_err(e IError) { |
| 7 | h.err = e |
| 8 | } |
| 9 | |
| 10 | fn test_direct_assignment() { |
| 11 | mut h := Holder{} |
| 12 | assert h.err == none |
| 13 | h.err = error('boom') |
| 14 | got := h.err or { panic('expected Some, got none') } |
| 15 | assert got.msg() == 'boom' |
| 16 | } |
| 17 | |
| 18 | fn test_method_assignment() { |
| 19 | mut h := Holder{} |
| 20 | h.set_err(error('method boom')) |
| 21 | got := h.err or { panic('expected Some, got none') } |
| 22 | assert got.msg() == 'method boom' |
| 23 | } |
| 24 |