git @ Cat's Eye Technologies Falderal / 0cb92e7
You can run tests with named functionalities now! catseye 10 years ago
2 changed file(s) with 17 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
4141 Tests for everySecond
4242 ---------------------
4343
44 -> Tests for Haskell function Test.Falderal.Demo:everySecond
44 -> Tests for functionality "Retain every second character"
4545
4646 Every second symbol in the string is retained.
4747
144144 convertLinesToBlocks ((Pragma text):rest) fn fnMap =
145145 case parsePragma text of
146146 TestsFor (NamedFunctionality name) ->
147 -- fn = look up name in fnMap
148 convertLinesToBlocks rest fn fnMap
147 case lookup name fnMap of
148 Just fn' -> convertLinesToBlocks rest fn' fnMap
149 Nothing -> error ("Can't find " ++ name ++ " in " ++ (show fnMap))
149150 TestsFor fn' ->
150151 convertLinesToBlocks rest fn' fnMap
151152 _ ->
156157 convertLinesToBlocks (_:rest) fn fnMap =
157158 convertLinesToBlocks rest fn fnMap
158159 convertLinesToBlocks [] _ _ = []
159
160160
161161 collectFunctionalityDefinitions ((Pragma text):rest) =
162162 case parsePragma text of
204204
205205 functionalities = [
206206 parseHaskellFunctionality,
207 parseShellFunctionality
207 parseShellFunctionality,
208 parseNamedFunctionality
208209 ]
209210
210211 tryFunctionalities [] text =
234235 Nothing ->
235236 Nothing
236237
238 parseNamedFunctionality text =
239 case consumeWords ["functionality"] text of
240 Just specifier ->
241 let
242 (name, _) = parseQuotedString specifier
243 in
244 Just $ NamedFunctionality name
245 Nothing ->
246 Nothing
247
237248 parseSpecifier specifier =
238249 let
239250 (m, f) = break (\y -> y == ':') specifier
249260 let
250261 functionality = tryFunctionalities functionalities funky
251262 in
252 FunctionalityDefinition text functionality
263 FunctionalityDefinition name functionality
253264 Nothing ->
254265 error $ "bad functionality definition: " ++ text
255266