diff --git a/haskell/Main.hs b/haskell/Main.hs index 2ca178b..f6a4f1e 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.pack t) pure $ + test (T.pack t) pure $ [ Day1.puzzle , Day2.puzzle , Day3.puzzle @@ -44,7 +44,7 @@ tests = ] <&> \Puzzle{number = show -> pt, parser, parts, extraTests} -> testLazy - (mkTestName $ T.pack pt) + (T.pack pt) ( \() -> do let fp = "../inputs/" <> t <> "/" <> pt input <- @@ -58,7 +58,7 @@ tests = ) $ ( finites <&> \(n@(show . succ @Int . fromIntegral -> nt)) -> test - (mkTestName $ T.pack nt) + (T.pack nt) (\(_, rs, _) -> golden ("../outputs/" <> t <> "/" <> pt <> "/" <> nt) $ rs n <> "\n") [] ) diff --git a/haskell/Pre.hs b/haskell/Pre.hs index dbd0965..290188e 100644 --- a/haskell/Pre.hs +++ b/haskell/Pre.hs @@ -68,7 +68,6 @@ module Pre ( test, testLazy, TestName, - mkTestName, getTestTree, displayTestResultsConsole, runTests, @@ -266,14 +265,14 @@ newtype Test m a = Test (ExceptT TestFailure m a) ) -- | See `testLazy` for avoiding the `NFData` constraint. -test :: (NFData output) => TestName -> (input -> Test m output) -> [TestTree m output] -> TestTree m input -test n f = TestTree n $ TestCase f +test :: (NFData output) => Text -> (input -> Test m output) -> [TestTree m output] -> TestTree m input +test n f = TestTree (TestName n) $ TestCase f {- | This is `test` without the `NFData` constraint. It doesn't force the output before completion, which means that reported timings may be less accurate. -} -testLazy :: TestName -> (input -> Test m output) -> [TestTree m output] -> TestTree m input -testLazy n f = TestTree n $ TestCaseLazy f +testLazy :: Text -> (input -> Test m output) -> [TestTree m output] -> TestTree m input +testLazy n f = TestTree (TestName n) $ TestCaseLazy f data TestResult = Pass TestName NominalDiffTime [TestResult] @@ -289,9 +288,6 @@ data TestFailure newtype TestName = TestName Text deriving newtype (IsString, Show) -mkTestName :: Text -> TestName -mkTestName = TestName - getTestTree :: TestTree m r -> Tree TestName getTestTree (TestTree name _ ts) = Node name $ map getTestTree ts diff --git a/haskell/Puzzles/Day4.hs b/haskell/Puzzles/Day4.hs index 8681a90..fbad03d 100644 --- a/haskell/Puzzles/Day4.hs +++ b/haskell/Puzzles/Day4.hs @@ -41,7 +41,7 @@ puzzle = in map ( \n -> test - (mkTestName $ T.show n) + (T.show n) ( \frames -> do g <- lookupFrame n frames golden (path <> "frames/" <> show n) $ drawGrid g