on 7bb5ff4 help sign in
reflex/test/Reflex/TestPlan.hs
44 lines 1.3 kB history raw
1{-# LANGUAGE FunctionalDependencies, BangPatterns, UndecidableInstances, ConstraintKinds, GADTs, ScopedTypeVariables, FlexibleInstances, MultiParamTypeClasses, GeneralizedNewtypeDeriving, RankNTypes, RecursiveDo, FlexibleContexts, StandaloneDeriving #-}
2module Reflex.TestPlan
3 ( TestPlan(..)
5 , TestCase (..)
6 , testE, testB
7 , TestE, TestB
9 , planList
11 ) where
13import Reflex.Class
14import Control.Monad.Fix
15import Data.Word
18import Prelude
20class (Reflex t, MonadHold t m, MonadFix m) => TestPlan t m where
21 -- | Speicify a plan of an input Event firing
22 -- Occurances must be in the future (i.e. Time > 0)
23 -- Initial specification is
25 plan :: [(Word, a)] -> m (Event t a)
28planList :: TestPlan t m => [a] -> m (Event t a)
29planList xs = plan $ zip [1..] xs
31type TestE a = forall t m. TestPlan t m => m (Event t a)
32type TestB a = forall t m. TestPlan t m => m (Behavior t a)
34data TestCase where
35 TestE :: (Show a, Eq a) => TestE a -> TestCase
36 TestB :: (Show a, Eq a) => TestB a -> TestCase
38-- Helpers to declare test cases
39testE :: (Eq a, Show a) => String -> TestE a -> (String, TestCase)
40testE name test = (name, TestE test)
42testB :: (Eq a, Show a) => String -> TestB a -> (String, TestCase)
43testB name test = (name, TestB test)