| 1 | pub struct ParamPrecos { |
| 2 | pub: |
| 3 | code string @[required] |
| 4 | table_ref ?i64 |
| 5 | } |
| 6 | |
| 7 | fn test_none() { |
| 8 | pp := ParamPrecos{ |
| 9 | code: 'V' |
| 10 | } |
| 11 | |
| 12 | tx_ref := match pp.table_ref { |
| 13 | none { 'num: none' } |
| 14 | else { 'num: ${pp.table_ref?}' } |
| 15 | } |
| 16 | |
| 17 | assert tx_ref == 'num: none' |
| 18 | } |
| 19 | |
| 20 | fn test_not_none() { |
| 21 | pp := ParamPrecos{ |
| 22 | code: 'V' |
| 23 | table_ref: 123 |
| 24 | } |
| 25 | |
| 26 | tx_ref := match pp.table_ref { |
| 27 | none { 'num: none' } |
| 28 | else { 'num: ${pp.table_ref?}' } |
| 29 | } |
| 30 | |
| 31 | assert tx_ref == 'num: 123' |
| 32 | } |
| 33 | |