trycmd
trycmd copied to clipboard
Incorrect `assert_data_eq` report
Recently, I ran into a failure like this:[^1]
fn main() {
let actual = r#" before_tokens: "["let", "(", "_", ",", "ref_count"]","#;
let expected = r#" before_tokens: "[..]","#;
snapbox::assert_data_eq!(actual, expected);
}
From what I can tell, the problem is:
-
expectedgets broken up into sectionsbefore_tokens: "and",. - The latter appears in the middle of
actualjust afterlet. - When there are no more sections to process,
line_matchesreturns false becauseremainderis not empty: https://github.com/assert-rs/snapbox/blob/90fd7f0c6d9e0d462bfcaa3a8df66a462a2be28a/crates/snapbox/src/filter/pattern.rs#L599
Does that sound about right?
If so, would you be open to a reimplementation of line_matches that uses regex Captures?
[^1]: Corrected per @Muscraft's comment: https://github.com/assert-rs/snapbox/issues/411#issuecomment-3539740339