Simplify test name handling
We keep the internal type safety, while making things easier for users.
This commit is contained in:
parent
f634b9b42d
commit
fb2d412f95
@ -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")
|
||||
[]
|
||||
)
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user