@@ -68,12 +68,20 @@ showDiff (Second w) = "NOW " <> w
6868showDiff (Both w _) = w
6969
7070-- | Compare the expected output recorded in the 'EvalExpr' with the actual
71- -- output @out@. When diffing is enabled and there is a recorded output, return
72- -- a line-by-line diff (see 'showDiffs'); otherwise return @out@ unchanged.
71+ -- output @out@, returning the result as one 'T.Text' per line. When diffing is
72+ -- enabled and there is a recorded output, return a line-by-line diff (see
73+ -- 'showDiffs'); otherwise return @out@ unchanged.
74+ --
75+ -- @out@ is normalised to one element per line first: a multi-line result
76+ -- arrives here as a single element with embedded newlines, whereas the recorded
77+ -- output is already split per line, and 'getDiff' compares element-wise. Without
78+ -- this, identical multi-line results would be reported as entirely changed.
7379evalExprCheck :: Bool -> (Section , EvalExpr ) -> [T. Text ] -> [T. Text ]
7480evalExprCheck diff (section, evalExpr) out
75- | not diff || null (evalExprOutput evalExpr) || sectionLanguage section == Plain = out
76- | otherwise = showDiffs $ getDiff (map T. pack $ evalExprOutput evalExpr) out
81+ | not diff || null (evalExprOutput evalExpr) || sectionLanguage section == Plain = outLines
82+ | otherwise = showDiffs $ getDiff (map T. pack $ evalExprOutput evalExpr) outLines
83+ where
84+ outLines = concatMap T. lines out
7785
7886-- | The number of (expression lines, result lines) an 'EvalExpr' occupies.
7987evalExprLengths :: EvalExpr -> (Int , Int )
0 commit comments