IOSpec 0.2 → 0.2.1
raw patch · 13 files changed
+34/−22 lines, 13 filesdep ~QuickCheckdep ~basePVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: QuickCheck, base
API changes (from Hackage documentation)
- Test.IOSpec.Fork: instance Executable ForkS
- Test.IOSpec.Fork: instance Functor ForkS
- Test.IOSpec.IORef: instance Executable IORefS
- Test.IOSpec.IORef: instance Functor IORefS
- Test.IOSpec.MVar: instance Executable MVarS
- Test.IOSpec.MVar: instance Functor MVarS
- Test.IOSpec.MVar: instance Typeable1 MVar
- Test.IOSpec.STM: instance Executable STMS
- Test.IOSpec.STM: instance Functor STM
- Test.IOSpec.STM: instance Functor STMS
- Test.IOSpec.STM: instance Monad STM
- Test.IOSpec.Teletype: instance Executable Teletype
- Test.IOSpec.Teletype: instance Functor Teletype
- Test.IOSpec.Types: instance [overlap ok] Functor f => Functor (IOSpec f)
- Test.IOSpec.Types: instance [overlap ok] Functor f => Monad (IOSpec f)
- Test.IOSpec.Types: instance [overlap ok] Functor f => f :<: f
- Test.IOSpec.VirtualMachine: instance (Executable f, Executable g) => Executable (f :+: g)
- Test.IOSpec.VirtualMachine: instance Arbitrary Scheduler
- Test.IOSpec.VirtualMachine: instance Arbitrary ThreadId
- Test.IOSpec.VirtualMachine: instance Eq ThreadId
- Test.IOSpec.VirtualMachine: instance Functor Effect
- Test.IOSpec.VirtualMachine: instance Monad Effect
- Test.IOSpec.VirtualMachine: instance Show Scheduler
- Test.IOSpec.VirtualMachine: instance Show ThreadId
+ Test.IOSpec.Fork: instance [overlap ok] Executable ForkS
+ Test.IOSpec.Fork: instance [overlap ok] Functor ForkS
+ Test.IOSpec.IORef: instance [overlap ok] Executable IORefS
+ Test.IOSpec.IORef: instance [overlap ok] Functor IORefS
+ Test.IOSpec.MVar: instance [overlap ok] Executable MVarS
+ Test.IOSpec.MVar: instance [overlap ok] Functor MVarS
+ Test.IOSpec.MVar: instance [overlap ok] Typeable1 MVar
+ Test.IOSpec.STM: instance [overlap ok] Executable STMS
+ Test.IOSpec.STM: instance [overlap ok] Functor STM
+ Test.IOSpec.STM: instance [overlap ok] Functor STMS
+ Test.IOSpec.STM: instance [overlap ok] Monad STM
+ Test.IOSpec.Teletype: instance [overlap ok] Executable Teletype
+ Test.IOSpec.Teletype: instance [overlap ok] Functor Teletype
+ Test.IOSpec.Types: instance [overlap ok] (Functor f) => Functor (IOSpec f)
+ Test.IOSpec.Types: instance [overlap ok] (Functor f) => Monad (IOSpec f)
+ Test.IOSpec.Types: instance [overlap ok] (Functor f) => f :<: f
+ Test.IOSpec.VirtualMachine: instance [overlap ok] (Eq a) => Eq (Effect a)
+ Test.IOSpec.VirtualMachine: instance [overlap ok] (Executable f, Executable g) => Executable (f :+: g)
+ Test.IOSpec.VirtualMachine: instance [overlap ok] Arbitrary Scheduler
+ Test.IOSpec.VirtualMachine: instance [overlap ok] Arbitrary ThreadId
+ Test.IOSpec.VirtualMachine: instance [overlap ok] CoArbitrary ThreadId
+ Test.IOSpec.VirtualMachine: instance [overlap ok] Eq ThreadId
+ Test.IOSpec.VirtualMachine: instance [overlap ok] Functor Effect
+ Test.IOSpec.VirtualMachine: instance [overlap ok] Monad Effect
+ Test.IOSpec.VirtualMachine: instance [overlap ok] Show Scheduler
+ Test.IOSpec.VirtualMachine: instance [overlap ok] Show ThreadId
- Test.IOSpec.Fork: forkIO :: (Executable f, ForkS :<: g) => IOSpec f a -> IOSpec g ThreadId
+ Test.IOSpec.Fork: forkIO :: (Executable f, :<: ForkS g) => IOSpec f a -> IOSpec g ThreadId
- Test.IOSpec.IORef: modifyIORef :: (Typeable a, IORefS :<: f) => IORef a -> (a -> a) -> IOSpec f ()
+ Test.IOSpec.IORef: modifyIORef :: (Typeable a, :<: IORefS f) => IORef a -> (a -> a) -> IOSpec f ()
- Test.IOSpec.IORef: newIORef :: (Typeable a, IORefS :<: f) => a -> IOSpec f (IORef a)
+ Test.IOSpec.IORef: newIORef :: (Typeable a, :<: IORefS f) => a -> IOSpec f (IORef a)
- Test.IOSpec.IORef: readIORef :: (Typeable a, IORefS :<: f) => IORef a -> IOSpec f a
+ Test.IOSpec.IORef: readIORef :: (Typeable a, :<: IORefS f) => IORef a -> IOSpec f a
- Test.IOSpec.IORef: writeIORef :: (Typeable a, IORefS :<: f) => IORef a -> a -> IOSpec f ()
+ Test.IOSpec.IORef: writeIORef :: (Typeable a, :<: IORefS f) => IORef a -> a -> IOSpec f ()
- Test.IOSpec.MVar: newEmptyMVar :: (Typeable a, MVarS :<: f) => IOSpec f (MVar a)
+ Test.IOSpec.MVar: newEmptyMVar :: (Typeable a, :<: MVarS f) => IOSpec f (MVar a)
- Test.IOSpec.MVar: putMVar :: (Typeable a, MVarS :<: f) => MVar a -> a -> IOSpec f ()
+ Test.IOSpec.MVar: putMVar :: (Typeable a, :<: MVarS f) => MVar a -> a -> IOSpec f ()
- Test.IOSpec.MVar: takeMVar :: (Typeable a, MVarS :<: f) => MVar a -> IOSpec f a
+ Test.IOSpec.MVar: takeMVar :: (Typeable a, :<: MVarS f) => MVar a -> IOSpec f a
- Test.IOSpec.STM: atomically :: STMS :<: f => STM a -> IOSpec f a
+ Test.IOSpec.STM: atomically :: (:<: STMS f) => STM a -> IOSpec f a
- Test.IOSpec.STM: newTVar :: Typeable a => a -> STM (TVar a)
+ Test.IOSpec.STM: newTVar :: (Typeable a) => a -> STM (TVar a)
- Test.IOSpec.STM: readTVar :: Typeable a => TVar a -> STM a
+ Test.IOSpec.STM: readTVar :: (Typeable a) => TVar a -> STM a
- Test.IOSpec.STM: writeTVar :: Typeable a => TVar a -> a -> STM ()
+ Test.IOSpec.STM: writeTVar :: (Typeable a) => TVar a -> a -> STM ()
- Test.IOSpec.Teletype: getChar :: :<: Teletype f => IOSpec f Char
+ Test.IOSpec.Teletype: getChar :: (:<: Teletype f) => IOSpec f Char
- Test.IOSpec.Teletype: getLine :: Teletype :<: f => IOSpec f String
+ Test.IOSpec.Teletype: getLine :: (:<: Teletype f) => IOSpec f String
- Test.IOSpec.Teletype: putChar :: Teletype :<: f => Char -> IOSpec f ()
+ Test.IOSpec.Teletype: putChar :: (:<: Teletype f) => Char -> IOSpec f ()
- Test.IOSpec.Teletype: putStr :: Teletype :<: f => String -> IOSpec f ()
+ Test.IOSpec.Teletype: putStr :: (:<: Teletype f) => String -> IOSpec f ()
- Test.IOSpec.Teletype: putStrLn :: Teletype :<: f => String -> IOSpec f ()
+ Test.IOSpec.Teletype: putStrLn :: (:<: Teletype f) => String -> IOSpec f ()
- Test.IOSpec.Types: foldIOSpec :: Functor f => (a -> b) -> (f b -> b) -> IOSpec f a -> b
+ Test.IOSpec.Types: foldIOSpec :: (Functor f) => (a -> b) -> (f b -> b) -> IOSpec f a -> b
- Test.IOSpec.Types: inject :: g :<: f => g (IOSpec f a) -> IOSpec f a
+ Test.IOSpec.Types: inject :: (:<: g f) => g (IOSpec f a) -> IOSpec f a
- Test.IOSpec.VirtualMachine: class Functor f => Executable f
+ Test.IOSpec.VirtualMachine: class (Functor f) => Executable f
- Test.IOSpec.VirtualMachine: evalIOSpec :: Executable f => IOSpec f a -> Scheduler -> Effect a
+ Test.IOSpec.VirtualMachine: evalIOSpec :: (Executable f) => IOSpec f a -> Scheduler -> Effect a
- Test.IOSpec.VirtualMachine: execIOSpec :: Executable f => IOSpec f a -> Scheduler -> Store
+ Test.IOSpec.VirtualMachine: execIOSpec :: (Executable f) => IOSpec f a -> Scheduler -> Store
- Test.IOSpec.VirtualMachine: runIOSpec :: Executable f => IOSpec f a -> Scheduler -> Effect (a, Store)
+ Test.IOSpec.VirtualMachine: runIOSpec :: (Executable f) => IOSpec f a -> Scheduler -> Effect (a, Store)
- Test.IOSpec.VirtualMachine: step :: Executable f => f a -> VM (Step a)
+ Test.IOSpec.VirtualMachine: step :: (Executable f) => f a -> VM (Step a)
- Test.IOSpec.VirtualMachine: updateSoup :: Executable f => ThreadId -> IOSpec f a -> VM ()
+ Test.IOSpec.VirtualMachine: updateSoup :: (Executable f) => ThreadId -> IOSpec f a -> VM ()
Files
- IOSpec.cabal +5/−5
- examples/Channels.hs +2/−2
- examples/Echo.hs +3/−7
- examples/Sudoku.hs +0/−1
- src/Test/IOSpec.hs +2/−2
- src/Test/IOSpec/Fork.hs +1/−0
- src/Test/IOSpec/IORef.hs +1/−0
- src/Test/IOSpec/MVar.hs +1/−0
- src/Test/IOSpec/STM.hs +2/−0
- src/Test/IOSpec/Surrogate.hs +1/−0
- src/Test/IOSpec/Teletype.hs +1/−0
- src/Test/IOSpec/Types.hs +3/−3
- src/Test/IOSpec/VirtualMachine.hs +12/−2
IOSpec.cabal view
@@ -1,8 +1,8 @@ Name: IOSpec-Version: 0.2+Version: 0.2.1 License: BSD3 License-file: LICENSE-Author: Wouter Swierstra+Author: Wouter Swierstra, Yusaku Hashimoto Maintainer: Wouter Swierstra <wss@cs.nott.ac.uk> Homepage: http://www.cs.nott.ac.uk/~wss/repos/IOSpec Synopsis: A pure specification of the IO monad.@@ -42,9 +42,9 @@ with the source distribution. Category: Testing Build-Type: Simple-Build-Depends: base, mtl, QuickCheck < 2.0, Stream-Extensions: MultiParamTypeClasses-Ghc-options: -Wall -fglasgow-exts+Build-Depends: base >= 2 && < 4, mtl, QuickCheck >= 2 && < 3, Stream+Extensions: MultiParamTypeClasses, OverlappingInstances+Ghc-options: -Wall Hs-source-dirs: src Extra-source-files: README , examples/Channels.hs
examples/Channels.hs view
@@ -85,8 +85,8 @@ -- Using QuickCheck to generate a random stream, we can use the -- streamSched to implement a random scheduler -- thereby testing as -- many interleavings as possible.-chanProp :: [Int] -> Scheduler -> Bool-chanProp ints sched =+chanProp :: NonEmptyList Int -> Scheduler -> Bool+chanProp (NonEmpty ints) sched = fmap sort (evalIOSpec (chanTest ints) sched) === Done (sort ints)
examples/Echo.hs view
@@ -40,15 +40,11 @@ -- desired specification: that is that for every input the user -- enters, every finite prefix of runTT echo input and copy input is -- the same.-echoProp :: Int -> Stream.Stream Char -> Property-echoProp n input =- n > 0 ==>+echoProp :: Stream.Stream Char -> Property+echoProp input =+ forAll (choose (1,10000)) $ \n -> takeOutput n (withInput input (evalIOSpec echo singleThreaded)) == takeOutput n (withInput input copy)--instance Arbitrary Char where- arbitrary = choose ('a','z')- coarbitrary = variant . ord main = do Prelude.putStrLn "Testing echo..."
examples/Sudoku.hs view
@@ -289,7 +289,6 @@ arbitrary = do xs <- arbitrary return (Sudoku $ blankOut xs (concat solution))- coarbitrary = error "No instance coarbitrary for Sudoku grids" blankOut :: [Int] -> [Value] -> [[Value]] blankOut [] grid = chop (boxsize * boxsize) grid
src/Test/IOSpec.hs view
@@ -7,7 +7,7 @@ , module Test.IOSpec.STM , module Test.IOSpec.Teletype -- * The basic types- , module Test.IOSpec.Types+ , module Test.IOSpec.Types -- * The virtual machine , module Test.IOSpec.VirtualMachine ) where@@ -17,5 +17,5 @@ import Test.IOSpec.IORef import Test.IOSpec.STM import Test.IOSpec.Teletype-import Test.IOSpec.Types+import Test.IOSpec.Types (IOSpec, (:+:)(..), inject, (:<:)) import Test.IOSpec.VirtualMachine
src/Test/IOSpec/Fork.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE ExistentialQuantification, FlexibleContexts #-} -- | A pure specification of 'forkIO'. module Test.IOSpec.Fork (
src/Test/IOSpec/IORef.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE FlexibleContexts #-} -- | A pure specification of mutable variables. module Test.IOSpec.IORef (
src/Test/IOSpec/MVar.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE DeriveDataTypeable, FlexibleContexts #-} -- | A pure specification of basic operations on MVars. module Test.IOSpec.MVar
src/Test/IOSpec/STM.hs view
@@ -1,3 +1,5 @@+{-# LANGUAGE ExistentialQuantification, FlexibleContexts #-}+ module Test.IOSpec.STM ( -- * The specification of STM
src/Test/IOSpec/Surrogate.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE EmptyDataDecls #-} -- | This module contains a few type signatures to help replace pure -- specifications by their effectful counterparts. module Test.IOSpec.Surrogate
src/Test/IOSpec/Teletype.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE FlexibleContexts #-} -- | A pure specification of getChar and putChar. module Test.IOSpec.Teletype (
src/Test/IOSpec/Types.hs view
@@ -1,4 +1,4 @@-{-# OPTIONS_GHC -fallow-overlapping-instances#-}+{-# LANGUAGE OverlappingInstances, TypeOperators, FlexibleInstances #-} -- | This module contains the basic data types underlying the -- 'IOSpec' library. Most of the types and classes in this module -- are described in@@ -33,8 +33,8 @@ -- | The fold over 'IOSpec' values. foldIOSpec :: Functor f => (a -> b) -> (f b -> b) -> IOSpec f a -> b-foldIOSpec pure _ (Pure x) = pure x-foldIOSpec pure impure (Impure t) = impure (fmap (foldIOSpec pure impure) t)+foldIOSpec pure _ (Pure x) = pure x+foldIOSpec pure impure (Impure t) = impure (fmap (foldIOSpec pure impure) t) -- | The coproduct of functors data (f :+: g) x = Inl (f x) | Inr (g x)
src/Test/IOSpec/VirtualMachine.hs view
@@ -1,3 +1,5 @@+{-# LANGUAGE ExistentialQuantification, TypeOperators #-}+ -- | The virtual machine on which the specifications execute. module Test.IOSpec.VirtualMachine (@@ -50,6 +52,8 @@ instance Arbitrary ThreadId where arbitrary = liftM ThreadId arbitrary++instance CoArbitrary ThreadId where coarbitrary (ThreadId k) = coarbitrary k newtype Scheduler =@@ -57,8 +61,6 @@ instance Arbitrary Scheduler where arbitrary = liftM streamSched arbitrary- coarbitrary = internalError- "Test.IOSpec: no definition of coarbitrary for Schedulers." instance Show Scheduler where show _ = "Test.IOSpec.Scheduler"@@ -215,6 +217,14 @@ (ReadChar t) >>= f = ReadChar (\c -> t c >>= f) (Print c t) >>= f = Print c (t >>= f) (Fail msg) >>= _ = Fail msg++instance Eq a => Eq (Effect a) where+ (Done x) == (Done y) = x == y+ (ReadChar f) == (ReadChar g) =+ all (\x -> f x == g x) [minBound .. maxBound]+ (Print c t) == (Print d u) = c == d && t == u+ (Fail s) == (Fail t) = s == t+ _ == _ = False -- $schedulerDoc --