From f634b9b42de7b4e4b97ff4579ac13f3aa66d632e Mon Sep 17 00:00:00 2001 From: George Thomas Date: Wed, 7 Jan 2026 00:43:51 +0000 Subject: [PATCH] Use `Text` for test names --- haskell/Main.hs | 6 +++--- haskell/Pre.hs | 8 ++++---- haskell/Puzzles/Day4.hs | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/haskell/Main.hs b/haskell/Main.hs index a10f6a0..2ca178b 100644 --- a/haskell/Main.hs +++ b/haskell/Main.hs @@ -30,7 +30,7 @@ tests :: TestTree IO () tests = test "tests" pure $ enumerate <&> \isRealData@(bool "examples" "real" -> t) -> - test (mkTestName t) pure $ + test (mkTestName $ T.pack t) pure $ [ Day1.puzzle , Day2.puzzle , Day3.puzzle @@ -44,7 +44,7 @@ tests = ] <&> \Puzzle{number = show -> pt, parser, parts, extraTests} -> testLazy - (mkTestName pt) + (mkTestName $ T.pack pt) ( \() -> do let fp = "../inputs/" <> t <> "/" <> pt input <- @@ -58,7 +58,7 @@ tests = ) $ ( finites <&> \(n@(show . succ @Int . fromIntegral -> nt)) -> test - (mkTestName nt) + (mkTestName $ T.pack nt) (\(_, rs, _) -> golden ("../outputs/" <> t <> "/" <> pt <> "/" <> nt) $ rs n <> "\n") [] ) diff --git a/haskell/Pre.hs b/haskell/Pre.hs index fc8439c..dbd0965 100644 --- a/haskell/Pre.hs +++ b/haskell/Pre.hs @@ -286,10 +286,10 @@ data TestFailure | GoldenFailure {expected :: Text, actual :: Text} deriving (Show) -newtype TestName = TestName String +newtype TestName = TestName Text deriving newtype (IsString, Show) -mkTestName :: String -> TestName +mkTestName :: Text -> TestName mkTestName = TestName getTestTree :: TestTree m r -> Tree TestName @@ -319,7 +319,7 @@ displayTestResultsConsole terminalWidth testResult = <> T.singleton icon <> " " <> setColour Dull White - <> T.pack name + <> name <> maybe mempty ( \_t@(showTime -> tt) -> @@ -327,7 +327,7 @@ displayTestResultsConsole terminalWidth testResult = ( fromIntegral $ maybe 3 - (\n -> n - (2 * indent + length name + T.length tt + 2)) + (\n -> n - (2 * indent + T.length name + T.length tt + 2)) terminalWidth ) " " diff --git a/haskell/Puzzles/Day4.hs b/haskell/Puzzles/Day4.hs index 14c35d0..8681a90 100644 --- a/haskell/Puzzles/Day4.hs +++ b/haskell/Puzzles/Day4.hs @@ -41,7 +41,7 @@ puzzle = in map ( \n -> test - (mkTestName $ show n) + (mkTestName $ T.show n) ( \frames -> do g <- lookupFrame n frames golden (path <> "frames/" <> show n) $ drawGrid g