2021-11-05 11:08:40 +01:00
|
|
|
import os
|
|
|
|
import toml
|
2021-11-18 12:27:59 +01:00
|
|
|
import toml.to
|
2021-11-05 11:08:40 +01:00
|
|
|
|
|
|
|
const (
|
|
|
|
toml_text = '[[albums]]
|
|
|
|
name = "Born to Run"
|
|
|
|
|
|
|
|
[[albums.songs]]
|
|
|
|
name = "Jungleland"
|
|
|
|
|
|
|
|
[[albums.songs]]
|
|
|
|
name = "Meeting Across the River"
|
|
|
|
|
|
|
|
[[albums]]
|
|
|
|
name = "Born in the USA"
|
|
|
|
|
|
|
|
[[albums.songs]]
|
|
|
|
name = "Glory Days"
|
|
|
|
|
|
|
|
[[albums.songs]]
|
|
|
|
name = "Dancing in the Dark"'
|
|
|
|
)
|
|
|
|
|
2022-03-18 22:32:06 +01:00
|
|
|
const fprefix = os.join_path(os.dir(@FILE), 'testdata', os.file_name(@FILE).all_before_last('.'))
|
2021-11-05 11:08:40 +01:00
|
|
|
|
2022-03-18 22:32:06 +01:00
|
|
|
fn test_nested_array_of_tables() ? {
|
2022-05-13 05:56:21 +02:00
|
|
|
mut toml_doc := toml.parse_text(toml_text)?
|
2021-11-05 11:08:40 +01:00
|
|
|
|
2022-03-18 22:32:06 +01:00
|
|
|
toml_json := to.json(toml_doc)
|
2021-11-05 11:08:40 +01:00
|
|
|
eprintln(toml_json)
|
2022-03-18 22:32:06 +01:00
|
|
|
|
2022-05-13 05:56:21 +02:00
|
|
|
assert toml_json == os.read_file(fprefix + '.out')?
|
2021-11-05 11:08:40 +01:00
|
|
|
}
|