From ef54d8ffa990d3e2bf981512202f73b7d800447a Mon Sep 17 00:00:00 2001 From: George Thomas Date: Tue, 2 Dec 2025 14:35:17 +0000 Subject: [PATCH] Inline main test function --- app/Main.hs | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/app/Main.hs b/app/Main.hs index ef63188..08e7dc5 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -23,25 +23,24 @@ main = defaultMain . localOption (Always :: UseColor) . testGroup "tests" - $ ["examples", "real"] <&> \s -> - testGroup s $ - puzzleTest s - <$> [ puzzle1 - , puzzle2 - ] - -puzzleTest :: FilePath -> Puzzle -> TestTree -puzzleTest t Puzzle{number, parser, parts} = - withResource (parseFile $ "inputs/" <> t <> "/" <> pt) mempty \input -> - testGroup pt $ - zip (map show [1 :: Int ..]) parts <&> \(n, pp) -> - goldenVsString n ("outputs/" <> t <> "/" <> pt <> "/" <> n) $ - BL.fromStrict . encodeUtf8 . pp <$> input - where - pt = show number - parseFile fp = - either (fail . ("parse failure: " <>) . errorBundlePretty) pure . runParser (parser <* eof) fp - =<< T.readFile fp + $ ["examples", "real"] <&> \t -> + testGroup t $ + [ puzzle1 + , puzzle2 + ] + <&> \Puzzle{number, parser, parts} -> + let + pt = show number + parseFile fp = + either (fail . ("parse failure: " <>) . errorBundlePretty) pure + . runParser (parser <* eof) fp + =<< T.readFile fp + in + withResource (parseFile $ "inputs/" <> t <> "/" <> pt) mempty \input -> + testGroup pt $ + zip (map show [1 :: Int ..]) parts <&> \(n, pp) -> + goldenVsString n ("outputs/" <> t <> "/" <> pt <> "/" <> n) $ + BL.fromStrict . encodeUtf8 . pp <$> input data Puzzle = forall input. Puzzle { number :: Word