on test-ci help sign in
reflex/test/Reflex/TestPlan.hs
52 lines 1.3 kB history raw
1{-# LANGUAGE ConstraintKinds #-}
2{-# LANGUAGE FlexibleContexts #-}
3{-# LANGUAGE FlexibleInstances #-}
4{-# LANGUAGE GADTs #-}
5{-# LANGUAGE MultiParamTypeClasses #-}
6{-# LANGUAGE RankNTypes #-}
7{-# LANGUAGE ScopedTypeVariables #-}
8{-# LANGUAGE UndecidableInstances #-}
9module Reflex.TestPlan
10 ( TestPlan(..)
12 , TestCase (..)
13 , testE, testB
14 , TestE, TestB
16 , planList
18 ) where
20import Control.DeepSeq
21import Control.Monad.Fix
22import Data.Word
23import Reflex.Class
26import Prelude
28class (Reflex t, MonadHold t m, MonadFix m) => TestPlan t m where
29 -- | Specify a plan of an input Event firing
30 -- Occurrences must be in the future (i.e. Time > 0)
31 -- Initial specification is
33 plan :: [(Word, a)] -> m (Event t a)
36planList :: TestPlan t m => [a] -> m (Event t a)
37planList xs = plan $ zip [1..] xs
39type TestE a = forall t m. TestPlan t m => m (Event t a)
40type TestB a = forall t m. TestPlan t m => m (Behavior t a)
42data TestCase where
43 TestE :: (Show a, Eq a, NFData a) => TestE a -> TestCase
44 TestB :: (Show a, Eq a, NFData a) => TestB a -> TestCase
46-- Helpers to declare test cases
47testE :: (Eq a, Show a, NFData a) => String -> TestE a -> (String, TestCase)
48testE name test = (name, TestE test)
50testB :: (Eq a, Show a, NFData a) => String -> TestB a -> (String, TestCase)
51testB name test = (name, TestB test)