mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
toml: fix multiline array bool scanner, add test (#18068)
This commit is contained in:
parent
b767c7d6f5
commit
27e1c20e3d
|
@ -142,7 +142,7 @@ pub fn (mut s Scanner) scan() !token.Token {
|
||||||
|
|
||||||
if util.is_key_char(byte_c) {
|
if util.is_key_char(byte_c) {
|
||||||
key := s.extract_key()
|
key := s.extract_key()
|
||||||
if !s.is_left_of_assign && (key == 'true' || key == 'false') {
|
if u8(s.peek(1)) != `=` && (key == 'true' || key == 'false') {
|
||||||
util.printdbg(@MOD + '.' + @STRUCT + '.' + @FN, 'identified a boolean "${key}" (${key.len})')
|
util.printdbg(@MOD + '.' + @STRUCT + '.' + @FN, 'identified a boolean "${key}" (${key.len})')
|
||||||
return s.new_token(.boolean, key, key.len)
|
return s.new_token(.boolean, key, key.len)
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,13 @@ strings = [
|
||||||
|
|
||||||
bools = [true, false, true, true]
|
bools = [true, false, true, true]
|
||||||
|
|
||||||
|
bools_br = [
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
true,
|
||||||
|
true
|
||||||
|
]
|
||||||
|
|
||||||
floats = [0.0, 1.0, 2.0, 3.0]
|
floats = [0.0, 1.0, 2.0, 3.0]
|
||||||
|
|
||||||
floats_br = [
|
floats_br = [
|
||||||
|
@ -57,6 +64,7 @@ struct User {
|
||||||
birthday toml.Date
|
birthday toml.Date
|
||||||
strings []string
|
strings []string
|
||||||
bools []bool
|
bools []bool
|
||||||
|
bools_br []bool
|
||||||
floats []f32
|
floats []f32
|
||||||
floats_br []f32
|
floats_br []f32
|
||||||
int_map map[string]int
|
int_map map[string]int
|
||||||
|
@ -80,6 +88,7 @@ fn test_reflect() {
|
||||||
assert user.birthday.str() == '1980-04-23'
|
assert user.birthday.str() == '1980-04-23'
|
||||||
assert user.strings == ['v matures', 'like rings', 'spread in the', 'water']
|
assert user.strings == ['v matures', 'like rings', 'spread in the', 'water']
|
||||||
assert user.bools == [true, false, true, true]
|
assert user.bools == [true, false, true, true]
|
||||||
|
assert user.bools_br == [true, false, true, true]
|
||||||
assert user.floats == [f32(0.0), 1.0, 2.0, 3.0]
|
assert user.floats == [f32(0.0), 1.0, 2.0, 3.0]
|
||||||
assert user.floats_br == [f32(0.0), 1.05, 2.025, 3.5001]
|
assert user.floats_br == [f32(0.0), 1.05, 2.025, 3.5001]
|
||||||
assert user.int_map == {
|
assert user.int_map == {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user