diff --git a/rslib/src/typeanswer.rs b/rslib/src/typeanswer.rs
index a5f384a8a..a0cb08ded 100644
--- a/rslib/src/typeanswer.rs
+++ b/rslib/src/typeanswer.rs
@@ -93,7 +93,7 @@ impl DiffContext {
"{}
",
if self.provided.is_empty() {
self.expected.iter().collect()
- } else if no_mistakes(&output.expected) {
+ } else if self.provided == self.expected {
provided
} else {
format!("{provided}
↓
{expected}")
@@ -102,10 +102,6 @@ impl DiffContext {
}
}
-fn no_mistakes(tokens: &[DiffToken]) -> bool {
- tokens.iter().all(|v| v.kind == DiffTokenKind::Good)
-}
-
fn prepare_expected(expected: &str) -> String {
let without_av = strip_av_tags(expected);
let without_newlines = LINEBREAKS.replace_all(&without_av, " ");
@@ -279,4 +275,28 @@ mod test {
fn whitespace_is_trimmed() {
assert_eq!(prepare_expected("
123
");
+ }
+
+ #[test]
+ fn correct_input_is_collapsed() {
+ let ctx = DiffContext::new("123", "123");
+ assert_eq!(
+ ctx.to_html(),
+ "123
"
+ );
+ }
+
+ #[test]
+ fn incorrect_input_is_not_collapsed() {
+ let ctx = DiffContext::new("123", "1123");
+ assert_eq!(
+ ctx.to_html(),
+ "1123
↓
123
"
+ );
+ }
}