File: Mock.hs

package info (click to toggle)
haskell-hspec 1.11.0-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 288 kB
  • sloc: haskell: 2,646; makefile: 5
file content (15 lines) | stat: -rw-r--r-- 313 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
module Mock where

import           Control.Applicative
import           Data.IORef

newtype Mock = Mock (IORef Int)

newMock :: IO Mock
newMock = Mock <$> newIORef 0

mockAction :: Mock -> IO ()
mockAction (Mock ref) = modifyIORef ref succ

mockCounter  :: Mock -> IO Int
mockCounter  (Mock ref) = readIORef ref