1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

toml: support multi-level map keys in arrays-of-tables (#12641)

This commit is contained in:
Larpon
2021-12-02 10:19:45 +01:00
committed by GitHub
parent ebfacca252
commit 5ab91dd471
5 changed files with 51 additions and 4 deletions

View File

@ -13,7 +13,6 @@ const (
'valid/example-v0.3.0.toml',
'valid/example-v0.4.0.toml',
'valid/datetime-truncate.toml', // Not considered valid since RFC 3339 doesn't permit > 6 ms digits ??
'valid/table-array-nest-no-keys.toml',
]
invalid_exceptions = [
'invalid/string-bad-line-ending-escape.toml',
@ -31,6 +30,7 @@ const (
'valid/table-array-many.toml',
'valid/table-array-one.toml',
'valid/table-array-nest.toml',
'valid/table-array-nest-no-keys.toml',
]
jq = os.find_abs_path_of_executable('jq') or { '' }

View File

@ -0,0 +1,18 @@
import os
import toml
import toml.to
fn test_array_of_tables_edge_case_file() {
toml_file :=
os.real_path(os.join_path(os.dir(@FILE), 'testdata', os.file_name(@FILE).all_before_last('.'))) +
'.toml'
toml_doc := toml.parse(toml_file) or { panic(err) }
toml_json := to.json(toml_doc)
out_file :=
os.real_path(os.join_path(os.dir(@FILE), 'testdata', os.file_name(@FILE).all_before_last('.'))) +
'.out'
out_file_json := os.read_file(out_file) or { panic(err) }
println(toml_json)
assert toml_json == out_file_json
}

View File

@ -0,0 +1 @@
{ "albums": [ { "songs": [ { }, { } ] } ], "artists": [ { "home": { "address": { } } } ] }

View File

@ -0,0 +1,6 @@
[[ albums ]]
[[ albums.songs ]]
[[ albums.songs ]]
[[ artists ]]
[ artists.home.address ]