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:
13
vlib/toml/tests/crlf_test.v
Normal file
13
vlib/toml/tests/crlf_test.v
Normal 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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user