git @ Cat's Eye Technologies Falderal / 951bafe
More correct handling of newlines in literalText. Passes, too! catseye 10 years ago
3 changed file(s) with 8 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
6464 formatLine (ExpectedError text) =
6565 (prefixEachLine "? " text)
6666 formatLine (LiteralText text) =
67 (prefixEachLine "" text) ++ "\n"
67 (prefixEachLine "" text)
6868 formatLine (QuotedCode text) =
6969 (prefixEachLine "> " text)
7070 formatLine (SectionHeading text) =
136136 coalesceLines lines (LiteralText (last ++ "\n" ++ more))
137137 coalesceLines ((QuotedCode more):lines) (QuotedCode last) =
138138 coalesceLines lines (QuotedCode (last ++ "\n" ++ more))
139 coalesceLines (line:lines) (LiteralText last) =
140 ((LiteralText (last ++ "\n")):coalesceLines lines line)
139141 coalesceLines (line:lines) last =
140142 (last:coalesceLines lines line)
141143
197199 stripLeading y all@(x:xs)
198200 | x == y = stripLeading y xs
199201 | otherwise = all
202
203 stripTrailing y str = reverse (stripLeading y (reverse str))
204
117117 reportEachTest [] = do
118118 return ()
119119 reportEachTest ((Failure literalText testText expected actual):rest) = do
120 reportText 8 "FAILED" (stripLeading '\n' literalText)
120 reportText 8 "FAILED" (stripLeading '\n' (stripTrailing '\n' literalText))
121 putStrLn ""
121122 reportText 8 "Input" testText
122123 reportText 8 "Expected" (show expected)
123124 reportText 8 "Actual" (show actual)