mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
toml: fix parsing array of tables (#12388)
This commit is contained in:
@@ -21,7 +21,6 @@ fn test_tables() {
|
||||
|
||||
toml_json := toml_doc.to_json()
|
||||
|
||||
eprintln(toml_json)
|
||||
assert toml_json == os.read_file(
|
||||
os.real_path(os.join_path(os.dir(@FILE), 'testdata', os.file_name(@FILE).all_before_last('.'))) +
|
||||
'.out') or { panic(err) }
|
||||
|
||||
33
vlib/toml/tests/array_of_tables_2_level_test.v
Normal file
33
vlib/toml/tests/array_of_tables_2_level_test.v
Normal file
@@ -0,0 +1,33 @@
|
||||
import os
|
||||
import toml
|
||||
|
||||
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"'
|
||||
)
|
||||
|
||||
fn test_nested_array_of_tables() {
|
||||
mut toml_doc := toml.parse(toml_text) or { panic(err) }
|
||||
|
||||
toml_json := toml_doc.to_json()
|
||||
|
||||
eprintln(toml_json)
|
||||
assert toml_json == os.read_file(
|
||||
os.real_path(os.join_path(os.dir(@FILE), 'testdata', os.file_name(@FILE).all_before_last('.'))) +
|
||||
'.out') or { panic(err) }
|
||||
}
|
||||
@@ -27,9 +27,7 @@ const (
|
||||
'datetime/no-leads-with-milli.toml',
|
||||
'datetime/no-leads.toml',
|
||||
// Key
|
||||
'key/duplicate.toml',
|
||||
'key/after-table.toml',
|
||||
'key/duplicate-keys.toml',
|
||||
'key/after-value.toml',
|
||||
'key/no-eol.toml',
|
||||
'key/after-array.toml',
|
||||
|
||||
1
vlib/toml/tests/testdata/array_of_tables_2_level_test.out
vendored
Normal file
1
vlib/toml/tests/testdata/array_of_tables_2_level_test.out
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{ "albums": [ { "name": "Born to Run", "songs": [ { "name": "Jungleland" }, { "name": "Meeting Across the River" } ] }, { "name": "Born in the USA", "songs": [ { "name": "Glory Days" }, { "name": "Dancing in the Dark" } ] } ] }
|
||||
Reference in New Issue
Block a user