Add way to specify extra tests
This commit is contained in:
parent
0508947a65
commit
8f67916e1a
@ -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]
|
||||
|
||||
@ -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]
|
||||
}
|
||||
|
||||
@ -37,6 +37,7 @@ puzzle =
|
||||
| p' == 0 -> abs c + 1
|
||||
| otherwise -> abs c
|
||||
]
|
||||
, extraTests = []
|
||||
}
|
||||
|
||||
data Direction = L | R
|
||||
|
||||
@ -25,6 +25,7 @@ puzzle =
|
||||
. concatMap
|
||||
(mapMaybe (\n -> guard (isRepetitionN n) $> n) . uncurry enumFromTo)
|
||||
]
|
||||
, extraTests = []
|
||||
}
|
||||
|
||||
newtype ID = ID Int
|
||||
|
||||
@ -26,6 +26,7 @@ puzzle =
|
||||
. sum
|
||||
. map (digitsToInt . fromMaybe (error "battery list too short") . maxBatteries 12)
|
||||
]
|
||||
, extraTests = []
|
||||
}
|
||||
|
||||
newtype Bank = Bank (NonEmpty Battery)
|
||||
|
||||
@ -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)]]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user