Merge pull request #94 from zofrex/require-newline-after-table
Require newline after table
This commit is contained in:
commit
50dfc8ac79
|
@ -447,7 +447,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn lookup_advanced_table() {
|
||||
let value: Value = r#"[table."name.other"] value = "my value""#.parse().unwrap();
|
||||
let value: Value = "[table.\"name.other\"]\nvalue = \"my value\"".parse().unwrap();
|
||||
let looked = value.lookup(r#"table."name.other".value"#).unwrap();
|
||||
assert_eq!(*looked, Value::String(String::from("my value")));
|
||||
}
|
||||
|
|
|
@ -271,6 +271,16 @@ impl<'a> Parser<'a> {
|
|||
values: BTreeMap::new(),
|
||||
defined: true,
|
||||
};
|
||||
self.ws();
|
||||
self.comment();
|
||||
if !self.newline() {
|
||||
self.errors.push(ParserError {
|
||||
lo: start,
|
||||
hi: start,
|
||||
desc: format!("expected a newline after table definition"),
|
||||
});
|
||||
return None
|
||||
}
|
||||
if !self.values(&mut table) { return None }
|
||||
if array {
|
||||
self.insert_array(&mut ret, &keys, Value::Table(table),
|
||||
|
|
|
@ -50,6 +50,10 @@ test!(float_no_leading_zero,
|
|||
include_str!("invalid/float-no-leading-zero.toml"));
|
||||
test!(float_no_trailing_digits,
|
||||
include_str!("invalid/float-no-trailing-digits.toml"));
|
||||
test!(key_after_array,
|
||||
include_str!("invalid/key-after-array.toml"));
|
||||
test!(key_after_table,
|
||||
include_str!("invalid/key-after-table.toml"));
|
||||
test!(key_empty,
|
||||
include_str!("invalid/key-empty.toml"));
|
||||
test!(key_hash,
|
||||
|
|
1
tests/invalid/key-after-array.toml
Normal file
1
tests/invalid/key-after-array.toml
Normal file
|
@ -0,0 +1 @@
|
|||
[[agencies]] owner = "S Cjelli"
|
1
tests/invalid/key-after-table.toml
Normal file
1
tests/invalid/key-after-table.toml
Normal file
|
@ -0,0 +1 @@
|
|||
[history] guard = "sleeping"
|
Loading…
Reference in a new issue