@@ -324,11 +324,13 @@ main = run tests =<< getArgs
324324
325325run :: [(String, Int -> IO (Bool,Int))] -> [String] -> IO ()
326326run tests args = do
327− let n = case args of
328− [s] -> read s
329− [] -> 100
330− _ -> error "too many arguments"
331− (results,passed) <- unzip <$> mapM (\(s,a) -> printf "%-40s: " s >> a n) tests
327+ let (n,names) = case args of
328+ (k:ts) -> (read k,ts)
329+ [] -> (100,[])
330+ (results,passed) <- fmap unzip . forM tests $ \(s,a) ->
331+ if null names || s `elem` names
332+ then printf "%-40s: " s >> a n
333+ else return (True,0)
332334 printf "Passed %d tests!\n" (sum passed)
333335 when (not . and $ results) $
334336 fail "Not all tests passed!"