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:
@ -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 { '' }
|
||||
|
18
vlib/toml/tests/array_of_tables_edge_case_2_test.v
Normal file
18
vlib/toml/tests/array_of_tables_edge_case_2_test.v
Normal 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
|
||||
}
|
1
vlib/toml/tests/testdata/array_of_tables_edge_case_2_test.out
vendored
Normal file
1
vlib/toml/tests/testdata/array_of_tables_edge_case_2_test.out
vendored
Normal file
@ -0,0 +1 @@
|
||||
{ "albums": [ { "songs": [ { }, { } ] } ], "artists": [ { "home": { "address": { } } } ] }
|
6
vlib/toml/tests/testdata/array_of_tables_edge_case_2_test.toml
vendored
Normal file
6
vlib/toml/tests/testdata/array_of_tables_edge_case_2_test.toml
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
[[ albums ]]
|
||||
[[ albums.songs ]]
|
||||
[[ albums.songs ]]
|
||||
|
||||
[[ artists ]]
|
||||
[ artists.home.address ]
|
Reference in New Issue
Block a user