Skip to content

Commit f1c3726

Browse files
committed
New testUnitIO function
1 parent b813e9d commit f1c3726

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

hedgehog-extras.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ library
102102
retry,
103103
stm,
104104
tar,
105+
tasty,
105106
tasty-discover,
106107
tasty-hedgehog,
107108
temporary,

src/Hedgehog/Extras/Test/Unit.hs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
module Hedgehog.Extras.Test.Unit
1313
( UnitIO(..)
14+
, testUnitIO
1415
) where
1516

1617
import Control.Monad.Base
@@ -30,6 +31,8 @@ import Lens.Micro
3031
import Test.Tasty.Discover
3132
import Test.Tasty.Hedgehog (testProperty)
3233

34+
import qualified Test.Tasty as T
35+
3336
newtype UnitIO a = UnitIO { runTestIO :: TestT (ResourceT IO) a }
3437
deriving newtype (Applicative)
3538
deriving newtype (Functor)
@@ -45,5 +48,9 @@ newtype UnitIO a = UnitIO { runTestIO :: TestT (ResourceT IO) a }
4548
deriving newtype (MonadThrow)
4649

4750
instance Tasty (UnitIO ()) where
48-
tasty info = pure . testProperty testName . H.withTests 1 . H.property . hoist runResourceT . H.test . runTestIO
51+
tasty info = pure . testUnitIO testName
4952
where testName = fromMaybe "" $ getLast (info ^. the @"name")
53+
54+
testUnitIO :: T.TestName -> UnitIO () -> T.TestTree
55+
testUnitIO testName =
56+
testProperty testName . H.withTests 1 . H.property . hoist runResourceT . H.test . runTestIO

0 commit comments

Comments
 (0)