summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2023-09-01 16:20:56 +0200
committerMartin Fischer <martin@push-f.com>2023-09-03 23:00:05 +0200
commitc8a8bcb95b725d91a7c4b7bc7623171f2a04fc67 (patch)
tree212f64c123be299d93bbc8afcd1c22c69f3d3684
parent55e6341d11aa4a51bb0a45e3719eb44c3706b0da (diff)
test: test comment data spans more thoroughly
-rw-r--r--tests/test_spans.rs47
1 files changed, 45 insertions, 2 deletions
diff --git a/tests/test_spans.rs b/tests/test_spans.rs
index 09f10f4..e856a19 100644
--- a/tests/test_spans.rs
+++ b/tests/test_spans.rs
@@ -202,13 +202,24 @@ fn comment_data_span() {
#[rustfmt::skip]
let cases = [
"<!-- Why are you looking at the source code? -->",
+ "<!-- Why are you looking at the source code? --",
+ "<!-- Why are you looking at the source code? -",
+ "<!-- Why are you looking at the source code?",
+ "<!--",
+ "<!-->",
+ "<!---",
+ "<!--->",
+ "<!-- Why are you looking at the source code? ->",
+ "<!-- Why are you looking at the source code? --!>",
+ "<!-- Why are you looking at the source code? --!",
// bogus comments
"<! Why are you looking at the source code? -->",
+ "<!",
];
let mut annotated = String::new();
- for case in cases {
+ for (idx, case) in cases.iter().enumerate() {
let labeler = |tokens: TokenIter| {
let Token::Comment(comment) = tokens
.filter(|t| !matches!(t, Token::Error { .. }))
@@ -219,15 +230,47 @@ fn comment_data_span() {
};
vec![(comment.data_span(), "")]
};
- assert_panics_but_should_not(|| assert_char_encoding_independence(case, labeler)); // FIXME
+
+ println!("{idx}");
+ if [
+ 0, 1, 2, 3, 8, 9, 10, 11, // FIXME
+ ]
+ .contains(&idx)
+ {
+ assert_panics_but_should_not(|| assert_char_encoding_independence(case, labeler));
+ } else {
+ assert_char_encoding_independence(case, labeler);
+ }
annotated.push_str(&test_and_annotate(case, labeler));
}
assert_snapshot!(annotated, @r###"
<!-- Why are you looking at the source code? -->
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ <!-- Why are you looking at the source code? --
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ <!-- Why are you looking at the source code? -
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ <!-- Why are you looking at the source code?
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ <!--
+ ^
+ <!-->
+ ^
+ <!---
+ ^
+ <!--->
+ ^
+ <!-- Why are you looking at the source code? ->
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ <!-- Why are you looking at the source code? --!>
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ <!-- Why are you looking at the source code? --!
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
<! Why are you looking at the source code? -->
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ <!
+ ^
"###);
for (idx, case) in cases.iter().enumerate() {