-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #117 from clash-lang/lucas/add-drivable-tuples
- Loading branch information
Showing
8 changed files
with
446 additions
and
241 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
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,79 @@ | ||
{-# LANGUAGE FlexibleContexts #-} | ||
{-# LANGUAGE FlexibleInstances #-} | ||
{-# LANGUAGE UndecidableInstances #-} | ||
{-# LANGUAGE UndecidableSuperClasses #-} | ||
{-# OPTIONS_HADDOCK hide #-} | ||
|
||
-- These types should be re-exported from the Protocols.Hedgehog module | ||
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) |
Oops, something went wrong.