Make Formatter slightly more Haskellesque and slightly less crude.
Chris Pressey
13 years ago
46 | 46 | testText <- readFile fileName |
47 | 47 | lines <- return $ transformLines $ lines testText |
48 | 48 | blocks <- return $ convertLinesToBlocks $ lines |
49 | outputText <- return $ formatBlocks blocks | |
49 | outputText <- return $ formatBlocks (formatBlock) blocks | |
50 | 50 | putStr outputText |
51 | 51 | |
52 | formatBlocks [] = "" | |
53 | formatBlocks ((Section sectionText):rest) = | |
54 | sectionText ++ (formatBlocks rest) | |
55 | formatBlocks ((Test literalText inputText expected):rest) = | |
56 | literalText ++ inputText ++ (show expected) ++ (formatBlocks rest) | |
52 | formatBlocks formatter blocks = foldl (++) "" (map (formatter) blocks) | |
53 | ||
54 | formatBlock (Section sectionText) = | |
55 | sectionText ++ "\n" | |
56 | formatBlock (Test literalText inputText expected) = | |
57 | literalText ++ "\n" ++ "| " ++ inputText ++ "\n> " ++ (show expected) ++ "\n" |