| 1 | import os |
| 2 | import toml |
| 3 | import toml.to |
| 4 | |
| 5 | const toml_table_text = ' |
| 6 | [[products]] |
| 7 | name = "Hammer" |
| 8 | sku = 738594937 |
| 9 | |
| 10 | [[products]] # empty table within the array |
| 11 | |
| 12 | [[products]] |
| 13 | name = "Nail" |
| 14 | sku = 284758393 |
| 15 | |
| 16 | color = "gray"' |
| 17 | |
| 18 | fn test_tables() { |
| 19 | mut toml_doc := toml.parse_text(toml_table_text) or { panic(err) } |
| 20 | |
| 21 | toml_json := to.json(toml_doc) |
| 22 | |
| 23 | assert toml_json == os.read_file( |
| 24 | os.real_path(os.join_path(os.dir(@FILE), 'testdata', os.file_name(@FILE).all_before_last('.'))) + |
| 25 | '.out') or { panic(err) } |
| 26 | } |
| 27 | |