diff --git a/haskell/Main.hs b/haskell/Main.hs index bdd1d98..91de52b 100644 --- a/haskell/Main.hs +++ b/haskell/Main.hs @@ -26,7 +26,7 @@ main = , Day3.puzzle , Day4.puzzle ] - <&> \Puzzle{number, parser, parts} -> + <&> \Puzzle{number, parser, parts, extraTests} -> let pt = show number parseFile fp = @@ -36,6 +36,9 @@ main = 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 + ) + <> [testGroup "extra" extraTests] diff --git a/haskell/Puzzle.hs b/haskell/Puzzle.hs index b137bfe..8f252bf 100644 --- a/haskell/Puzzle.hs +++ b/haskell/Puzzle.hs @@ -2,10 +2,12 @@ module Puzzle where import Data.Text (Text) import Data.Void +import Test.Tasty import Text.Megaparsec data Puzzle = forall input. Puzzle { number :: Word , parser :: Parsec Void Text input , parts :: [input -> Text] + , extraTests :: [TestTree] } diff --git a/haskell/Puzzles/Day1.hs b/haskell/Puzzles/Day1.hs index 49b1dd0..74883bb 100644 --- a/haskell/Puzzles/Day1.hs +++ b/haskell/Puzzles/Day1.hs @@ -37,6 +37,7 @@ puzzle = | p' == 0 -> abs c + 1 | otherwise -> abs c ] + , extraTests = [] } data Direction = L | R diff --git a/haskell/Puzzles/Day2.hs b/haskell/Puzzles/Day2.hs index 1026180..dbda2e1 100644 --- a/haskell/Puzzles/Day2.hs +++ b/haskell/Puzzles/Day2.hs @@ -25,6 +25,7 @@ puzzle = . concatMap (mapMaybe (\n -> guard (isRepetitionN n) $> n) . uncurry enumFromTo) ] + , extraTests = [] } newtype ID = ID Int diff --git a/haskell/Puzzles/Day3.hs b/haskell/Puzzles/Day3.hs index e3c484d..a07967e 100644 --- a/haskell/Puzzles/Day3.hs +++ b/haskell/Puzzles/Day3.hs @@ -26,6 +26,7 @@ puzzle = . sum . map (digitsToInt . fromMaybe (error "battery list too short") . maxBatteries 12) ] + , extraTests = [] } newtype Bank = Bank (NonEmpty Battery) diff --git a/haskell/Puzzles/Day4.hs b/haskell/Puzzles/Day4.hs index 4e8cb15..7685159 100644 --- a/haskell/Puzzles/Day4.hs +++ b/haskell/Puzzles/Day4.hs @@ -27,6 +27,7 @@ puzzle = . unfoldr ((\r -> guard (fst r /= 0) $> r) . (removeAccessibleRolls <<<<$>>>>) . findAccessible) . addCoords ] + , extraTests = [] } addCoords :: (Num a, Enum a) => [[c]] -> [[(V2 a, c)]]