More correct handling of newlines in literalText. Passes, too!
catseye
10 years ago
64 | 64 |
formatLine (ExpectedError text) =
|
65 | 65 |
(prefixEachLine "? " text)
|
66 | 66 |
formatLine (LiteralText text) =
|
67 | |
(prefixEachLine "" text) ++ "\n"
|
|
67 |
(prefixEachLine "" text)
|
68 | 68 |
formatLine (QuotedCode text) =
|
69 | 69 |
(prefixEachLine "> " text)
|
70 | 70 |
formatLine (SectionHeading text) =
|
136 | 136 |
coalesceLines lines (LiteralText (last ++ "\n" ++ more))
|
137 | 137 |
coalesceLines ((QuotedCode more):lines) (QuotedCode last) =
|
138 | 138 |
coalesceLines lines (QuotedCode (last ++ "\n" ++ more))
|
|
139 |
coalesceLines (line:lines) (LiteralText last) =
|
|
140 |
((LiteralText (last ++ "\n")):coalesceLines lines line)
|
139 | 141 |
coalesceLines (line:lines) last =
|
140 | 142 |
(last:coalesceLines lines line)
|
141 | 143 |
|
|
197 | 199 |
stripLeading y all@(x:xs)
|
198 | 200 |
| x == y = stripLeading y xs
|
199 | 201 |
| otherwise = all
|
|
202 |
|
|
203 |
stripTrailing y str = reverse (stripLeading y (reverse str))
|
|
204 |
|
117 | 117 |
reportEachTest [] = do
|
118 | 118 |
return ()
|
119 | 119 |
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 ""
|
121 | 122 |
reportText 8 "Input" testText
|
122 | 123 |
reportText 8 "Expected" (show expected)
|
123 | 124 |
reportText 8 "Actual" (show actual)
|