| 1 | import toml |
| 2 | |
| 3 | fn test_spaced_keys() { |
| 4 | str_value := 'V rocks!' |
| 5 | |
| 6 | toml_txt := ' |
| 7 | "o" . pq . r = "Yuk" |
| 8 | |
| 9 | [[ a . "b.c" ]] |
| 10 | d . e = "V rocks!" |
| 11 | |
| 12 | [ tube . test . "test.test" ] |
| 13 | h . "i.j." . "k" = "Cryptic" |
| 14 | ' |
| 15 | toml_doc := toml.parse_text(toml_txt) or { panic(err) } |
| 16 | mut value := toml_doc.value('a."b.c"[0].d.e') |
| 17 | assert value == toml.Any(str_value) |
| 18 | assert value as string == str_value |
| 19 | assert value.string() == str_value |
| 20 | |
| 21 | value = toml_doc.value('"o".pq.r') |
| 22 | assert value.string() == 'Yuk' |
| 23 | |
| 24 | value = toml_doc.value('tube.test."test.test".h."i.j."."k"') |
| 25 | assert value.string() == 'Cryptic' |
| 26 | } |
| 27 | |