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

toml: fix implicit allocation overwrite of existing table (#12793)

This commit is contained in:
Larpon
2021-12-11 14:21:46 +01:00
committed by GitHub
parent 9bf777c1ee
commit ba06eba39c
2 changed files with 35 additions and 8 deletions

View File

@@ -1,7 +1,8 @@
import toml
import strconv
const toml_text = '
const (
toml_text = '
modules = [ "ui", "toml" ]
errors = []
@@ -37,6 +38,17 @@ colors = [
]
'
toml_text_2 = "
[defaults]
run.flags = ['-f 1']
[[defaults.env]]
'RUN_PATH' = '\$OUT_PATH'
'RUN_TIME' = 5
'TEST_PATH' = '/tmp/test'
"
)
fn test_value_query_in_array() {
toml_doc := toml.parse(toml_text) or { panic(err) }
mut value := toml_doc.value('themes[0].colors[1]').string()
@@ -92,3 +104,10 @@ fn test_inf_and_nan_query() {
value_u64 = toml_doc.value('values.minus-inf').u64()
assert value_u64 == strconv.double_minus_infinity
}
fn test_any_value_query_2() {
toml_doc := toml.parse(toml_text_2) or { panic(err) }
defaults := toml_doc.value('defaults')
assert defaults.value('run.flags[0]').string() == '-f 1'
assert defaults.value('env[0].RUN_TIME').int() == 5
}