Skip to content

Instantly share code, notes, and snippets.

@tazjin
Created February 10, 2015 21:06
Show Gist options
  • Select an option

  • Save tazjin/4598b0e6646fc63b29c8 to your computer and use it in GitHub Desktop.

Select an option

Save tazjin/4598b0e6646fc63b29c8 to your computer and use it in GitHub Desktop.
Beautiful
-- | Test something with an in-memory acid-state
acidTest :: forall event query result.
(UpdateEvent event, MethodState event ~ HerbertState,
QueryEvent query, MethodState query ~ HerbertState,
MethodResult query ~ result)
=> String -- ^ Test description
-> HerbertState -- ^ Initial state for test
-> event -- ^ Event to test
-> query -- ^ Query to check
-> (result -> Bool) -- ^ Function to test query result
-> Assertion
acidTest desc initialState event query' checker = do
state <- openMemoryState initialState
update state event
result <- query state query'
assertBool desc $ checker result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment