-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move
BackPressure
and Simulate
to Protocols.Internal.Classes
- Loading branch information
Showing
9 changed files
with
253 additions
and
227 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
{-# LANGUAGE FlexibleContexts #-} | ||
{-# LANGUAGE RoleAnnotations #-} | ||
{-# OPTIONS_HADDOCK hide #-} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
{-# LANGUAGE FlexibleContexts #-} | ||
{-# LANGUAGE FlexibleInstances #-} | ||
{-# LANGUAGE UndecidableInstances #-} | ||
{-# LANGUAGE UndecidableSuperClasses #-} | ||
|
||
module Protocols.Hedgehog.Types where | ||
|
||
-- deepseq | ||
import Control.DeepSeq | ||
|
||
import qualified Clash.Prelude as C | ||
import Data.Proxy | ||
import GHC.Stack (HasCallStack) | ||
import Protocols.Internal.Types | ||
|
||
-- hedgehog | ||
import qualified Hedgehog as H | ||
|
||
-- | Superclass class to reduce syntactical noise. | ||
class (NFData a, C.NFDataX a, C.ShowX a, C.Show a, Eq a) => TestType a | ||
|
||
instance (NFData a, C.NFDataX a, C.ShowX a, C.Show a, Eq a) => TestType a | ||
|
||
-- | Options for 'expectN' function. See individual fields for more information. | ||
data ExpectOptions = ExpectOptions | ||
{ eoStopAfterEmpty :: Int | ||
-- ^ Stop sampling after seeing /n/ consecutive empty samples | ||
, eoSampleMax :: Int | ||
-- ^ Produce an error if the circuit produces more than /n/ valid samples. This | ||
-- is used to terminate (potentially) infinitely running circuits. | ||
-- | ||
-- This number is used to generate stall information, so setting it to | ||
-- unreasonable values will result in long runtimes. | ||
, eoResetCycles :: Int | ||
-- ^ Ignore first /n/ cycles | ||
, eoDriveEarly :: Bool | ||
-- ^ Start driving the circuit with its reset asserted. Circuits should | ||
-- never acknowledge data while this is happening. | ||
, eoTimeoutMs :: Maybe Int | ||
-- ^ Terminate the test after /n/ milliseconds. | ||
, eoTrace :: Bool | ||
-- ^ Trace data generation for debugging purposes | ||
} | ||
|
||
{- | Provides a way of comparing expected data with data produced by a | ||
protocol component. | ||
-} | ||
class | ||
( Drivable a | ||
, TestType (SimulateFwdType a) | ||
, TestType (ExpectType a) | ||
, -- Foldable requirement on Vec :( | ||
1 C.<= SimulateChannels a | ||
) => | ||
Test a | ||
where | ||
-- | Trim each channel to the lengths given as the third argument. See | ||
-- result documentation for failure modes. | ||
expectN :: | ||
(HasCallStack, H.MonadTest m) => | ||
Proxy a -> | ||
-- | Options, see 'ExpectOptions' | ||
ExpectOptions -> | ||
-- | Raw sampled data | ||
SimulateFwdType a -> | ||
-- | Depending on "ExpectOptions", fails the test if: | ||
-- | ||
-- * Circuit produced less data than expected | ||
-- * Circuit produced more data than expected | ||
-- | ||
-- If it does not fail, /SimulateFwdType a/ will contain exactly the number | ||
-- of expected data packets. | ||
-- | ||
-- TODO: | ||
-- Should probably return a 'Vec (SimulateChannels) Failures' | ||
-- in order to produce pretty reports. | ||
m (ExpectType a) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.