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

toml: fix hex values starting with a, e or E and comments ending with crlf (#12367)

This commit is contained in:
Larpon
2021-11-02 18:07:27 +01:00
committed by GitHub
parent 3fdbfca202
commit 99fd84dfe4
4 changed files with 34 additions and 6 deletions

View File

@@ -0,0 +1,13 @@
import toml
fn test_crlf() {
str_value := 'test string'
mut toml_txt := 'crlf_string = "test string"
# Comment with CRLF\r\n'
toml_doc := toml.parse(toml_txt) or { panic(err) }
value := toml_doc.value('crlf_string')
assert value == toml.Any(str_value)
assert value as string == str_value
assert value.string() == str_value
}

View File

@@ -68,3 +68,14 @@ open_sourced = "Jun 22 2019 20:20:28"'
value := toml_doc.value('v.open_sourced').string()
assert value == 'Jun 22 2019 20:20:28'
}
fn test_hex_values() {
// Regression test
// '0xb' is carefully chosen to include the 'b' character that also denotes binary via 0b prefix.
toml_txt := 'hex = 0xb'
toml_doc := toml.parse(toml_txt) or { panic(err) }
value := toml_doc.value('hex')
assert value as i64 == 11
assert value.i64() == 11
}