diff --git a/haskell/Main.hs b/haskell/Main.hs index 18ab874..bc07fc7 100644 --- a/haskell/Main.hs +++ b/haskell/Main.hs @@ -1,7 +1,9 @@ module Main (main) where +import Data.Bool import Data.ByteString.Lazy qualified as BL import Data.Functor +import Data.List.Extra import Data.Text.Encoding (encodeUtf8) import Data.Text.IO qualified as T import Puzzle @@ -19,7 +21,7 @@ main = defaultMain . localOption (Always :: UseColor) . testGroup "tests" - $ ["examples", "real"] <&> \t -> + $ enumerate <&> \isRealData@(bool "examples" "real" -> t) -> testGroup t $ [ Day1.puzzle , Day2.puzzle @@ -40,4 +42,4 @@ main = goldenVsString n ("../outputs/" <> t <> "/" <> pt <> "/" <> n) $ BL.fromStrict . encodeUtf8 . pp <$> input ) - <> [testGroup "extra" extraTests] + <> [testGroup "extra" $ extraTests isRealData ("../outputs/" <> t <> "/" <> pt <> "/extra/") input] diff --git a/haskell/Puzzle.hs b/haskell/Puzzle.hs index 8f252bf..9e5f6a0 100644 --- a/haskell/Puzzle.hs +++ b/haskell/Puzzle.hs @@ -9,5 +9,5 @@ data Puzzle = forall input. Puzzle { number :: Word , parser :: Parsec Void Text input , parts :: [input -> Text] - , extraTests :: [TestTree] + , extraTests :: Bool -> FilePath -> IO input -> [TestTree] } diff --git a/haskell/Puzzles/Day1.hs b/haskell/Puzzles/Day1.hs index 74883bb..ec27111 100644 --- a/haskell/Puzzles/Day1.hs +++ b/haskell/Puzzles/Day1.hs @@ -37,7 +37,7 @@ puzzle = | p' == 0 -> abs c + 1 | otherwise -> abs c ] - , extraTests = [] + , extraTests = mempty } data Direction = L | R diff --git a/haskell/Puzzles/Day2.hs b/haskell/Puzzles/Day2.hs index dbda2e1..053aae5 100644 --- a/haskell/Puzzles/Day2.hs +++ b/haskell/Puzzles/Day2.hs @@ -25,7 +25,7 @@ puzzle = . concatMap (mapMaybe (\n -> guard (isRepetitionN n) $> n) . uncurry enumFromTo) ] - , extraTests = [] + , extraTests = mempty } newtype ID = ID Int diff --git a/haskell/Puzzles/Day3.hs b/haskell/Puzzles/Day3.hs index a07967e..90f4bee 100644 --- a/haskell/Puzzles/Day3.hs +++ b/haskell/Puzzles/Day3.hs @@ -26,7 +26,7 @@ puzzle = . sum . map (digitsToInt . fromMaybe (error "battery list too short") . maxBatteries 12) ] - , extraTests = [] + , extraTests = mempty } newtype Bank = Bank (NonEmpty Battery) diff --git a/haskell/Puzzles/Day4.hs b/haskell/Puzzles/Day4.hs index 7685159..87900b4 100644 --- a/haskell/Puzzles/Day4.hs +++ b/haskell/Puzzles/Day4.hs @@ -27,7 +27,7 @@ puzzle = . unfoldr ((\r -> guard (fst r /= 0) $> r) . (removeAccessibleRolls <<<<$>>>>) . findAccessible) . addCoords ] - , extraTests = [] + , extraTests = mempty } addCoords :: (Num a, Enum a) => [[c]] -> [[(V2 a, c)]]