Tests for empty line comment, and fix in Rust

This commit is contained in:
Tony Garnock-Jones 2023-11-14 00:49:58 +01:00
parent f01cbf7443
commit 12a690b4b5
4 changed files with 27 additions and 0 deletions

View File

@ -56,6 +56,12 @@
annotation8a: @"Commas forbidden between @ and annotation in a collection" <ParseError "[@,a b]">
annotation9: @"Commas forbidden between annotation and underlying" <ParseError "@a, b">
annotation9a: @"Commas forbidden between annotation and underlying in a collection" <ParseError "[@a, b]">
annotation10: @"Line comment that's just hash-newline" <Test #x"85 B100 B000" #
0>
annotation11: @"Line comments: one hash-newline, one normal"
<Test #x"85 B100 85 B1066e6f726d616c B000" #
# normal
0>
bytes2: <Test #x"B20568656c6c6f" #"hello">
bytes2a: <Test @"Internal whitespace is allowed, not including commas" #x"B2 05 68 65 6c 6c 6f" #"hello">
bytes2b: @"Commas forbidden in internal whitespace" <ParseError "#x\"B2, 05, 68, 65, 6c, 6c, 6f\"">

View File

@ -56,6 +56,12 @@
annotation8a: @"Commas forbidden between @ and annotation in a collection" <ParseError "[@,a b]">
annotation9: @"Commas forbidden between annotation and underlying" <ParseError "@a, b">
annotation9a: @"Commas forbidden between annotation and underlying in a collection" <ParseError "[@a, b]">
annotation10: @"Line comment that's just hash-newline" <Test #x"85 B100 B000" #
0>
annotation11: @"Line comments: one hash-newline, one normal"
<Test #x"85 B100 85 B1066e6f726d616c B000" #
# normal
0>
bytes2: <Test #x"B20568656c6c6f" #"hello">
bytes2a: <Test @"Internal whitespace is allowed, not including commas" #x"B2 05 68 65 6c 6c 6f" #"hello">
bytes2b: @"Commas forbidden in internal whitespace" <ParseError "#x\"B2, 05, 68, 65, 6c, 6c, 6f\"">

View File

@ -520,6 +520,15 @@ impl<'de, 'src, N: NestedValue, Dec: DomainParse<N::Embedded>, S: BinarySource<'
continue 'restart;
}
}
b'\n' | b'\r' => {
if read_annotations {
let mut annotations = vec![N::new("")];
self.gather_annotations(&mut annotations)?;
self.prepend_annotations_to_next(annotations)?
} else {
continue 'restart;
}
}
b'f' => { self.require_delimiter("Delimiter must follow #f")?; N::new(false) }
b't' => { self.require_delimiter("Delimiter must follow #t")?; N::new(true) }
b'{' => self.read_set(read_annotations)?,

View File

@ -56,6 +56,12 @@
annotation8a: @"Commas forbidden between @ and annotation in a collection" <ParseError "[@,a b]">
annotation9: @"Commas forbidden between annotation and underlying" <ParseError "@a, b">
annotation9a: @"Commas forbidden between annotation and underlying in a collection" <ParseError "[@a, b]">
annotation10: @"Line comment that's just hash-newline" <Test #x"85 B100 B000" #
0>
annotation11: @"Line comments: one hash-newline, one normal"
<Test #x"85 B100 85 B1066e6f726d616c B000" #
# normal
0>
bytes2: <Test #x"B20568656c6c6f" #"hello">
bytes2a: <Test @"Internal whitespace is allowed, not including commas" #x"B2 05 68 65 6c 6c 6f" #"hello">
bytes2b: @"Commas forbidden in internal whitespace" <ParseError "#x\"B2, 05, 68, 65, 6c, 6c, 6f\"">