module Gen.Tasty.Hedgehog.Group
  ( fromGroup
  )
where

import           Prelude

import           Hedgehog (Group (..), Property)
import           Hedgehog.Internal.Property (GroupName (..), PropertyName (..))
import           Test.Tasty (TestTree, testGroup)
import           Test.Tasty.Hedgehog (testProperty)

fromGroup :: Group -> TestTree
fromGroup :: Group -> TestTree
fromGroup Group
group =
    TestName -> [TestTree] -> TestTree
testGroup (GroupName -> TestName
unGroupName (GroupName -> TestName) -> GroupName -> TestName
forall a b. (a -> b) -> a -> b
$ Group -> GroupName
groupName Group
group) ([TestTree] -> TestTree) -> [TestTree] -> TestTree
forall a b. (a -> b) -> a -> b
$
      ((PropertyName, Property) -> TestTree)
-> [(PropertyName, Property)] -> [TestTree]
forall a b. (a -> b) -> [a] -> [b]
map (PropertyName, Property) -> TestTree
mkTestTree (Group -> [(PropertyName, Property)]
groupProperties Group
group)
  where
    mkTestTree :: (PropertyName, Property) -> TestTree
    mkTestTree :: (PropertyName, Property) -> TestTree
mkTestTree (PropertyName
propName, Property
prop) = TestName -> Property -> TestTree
testProperty (PropertyName -> TestName
unPropertyName PropertyName
propName) Property
prop