1
0
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:
Larpon
2021-11-05 11:08:40 +01:00
committed by GitHub
parent db65b65f3c
commit 24cd619ff8
5 changed files with 70 additions and 17 deletions

View File

@@ -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) }

View 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) }
}

View File

@@ -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',

View 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" } ] } ] }