{-# LANGUAGE OverloadedStrings #-}
{-# OPTIONS_HADDOCK prune not-home #-}

{- |
Module      : Test.KeyedVals.Hspec
Copyright   : (c) 2022 Tim Emiola
Maintainer  : Tim Emiola <adetokunbo@emio.la>
SPDX-License-Identifier: BSD3

Uses "Test.Hspec" to validate the behaviour of a 'Handle' implementation
-}
module Test.KeyedVals.Hspec (
  -- * a test fixture
  checkHandle,

  -- * setup/teardown hspec tests
  setupFixture,
  closeFixture,

  -- * module re-export
  module Test.KeyedVals.Prelude,
) where

import qualified Test.KeyedVals.CheckHandle as LessTyped
import qualified Test.KeyedVals.CheckTypedHandle as Typed
import Test.KeyedVals.Prelude


checkHandle :: SpecWith (Handle IO)
checkHandle :: SpecWith (Handle IO)
checkHandle = do
  SpecWith (Handle IO)
LessTyped.spec
  SpecWith (Handle IO)
Typed.spec


setupFixture :: Handle IO -> IO (Handle IO)
setupFixture :: Handle IO -> IO (Handle IO)
setupFixture Handle IO
h = do
  forall (f :: * -> *) a. Functor f => f a -> f ()
void forall a b. (a -> b) -> a -> b
$ Handle IO -> IO (Handle IO)
LessTyped.setupFixture Handle IO
h
  forall (f :: * -> *) a. Functor f => f a -> f ()
void forall a b. (a -> b) -> a -> b
$ Handle IO -> IO (Handle IO)
Typed.setupFixture Handle IO
h
  forall (f :: * -> *) a. Applicative f => a -> f a
pure Handle IO
h


closeFixture :: Handle IO -> IO ()
closeFixture :: Handle IO -> IO ()
closeFixture = forall (m :: * -> *). Handle m -> m ()
close