Skip to content

Commit 207bbe3

Browse files
committed
add comments
1 parent 3e499f0 commit 207bbe3

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/lib.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ impl Expect {
338338
}
339339
line_start += line.len();
340340
}
341+
// `literal_start` points to the first character after `expect![`
341342
let (literal_start, line_indent) = target_line.unwrap();
342343

343344
let lit_to_eof = &file[literal_start..];
@@ -352,6 +353,9 @@ impl Expect {
352353
}
353354
}
354355

356+
/// Returns the byte index of the closing delimiter.
357+
///
358+
/// `arg_start_to_eof` is the part after `expect![`, with leading whitespaces trimmed.
355359
fn locate_end(arg_start_to_eof: &str) -> Option<usize> {
356360
match arg_start_to_eof.chars().next()? {
357361
c if c.is_whitespace() => panic!("skip whitespace before calling `locate_end`"),
@@ -836,8 +840,9 @@ line1
836840
macro_rules! check_locate {
837841
($( [[$s:literal]] ),* $(,)?) => {$({
838842
let lit = stringify!($s);
839-
let with_trailer = format!("{} \t]]\n", lit);
840-
assert_eq!(locate_end(&with_trailer), Some(lit.len()));
843+
let with_trailer = format!("[{} \t]]\n", lit);
844+
// ^ ^^ ^^ 5 additional chars
845+
assert_eq!(locate_end(&with_trailer), Some(4+lit.len()));
841846
})*};
842847
}
843848

@@ -850,7 +855,7 @@ line1
850855
);
851856

852857
// Check `expect![[ ]]` as well.
853-
assert_eq!(locate_end("]]"), Some(0));
858+
assert_eq!(locate_end("[]]"), Some(2));
854859
}
855860

856861
#[test]

0 commit comments

Comments
 (0)