Skip to content

Instantly share code, notes, and snippets.

@bohde
Created April 26, 2015 21:20
Show Gist options
  • Save bohde/57f4a5295f29ded4bf82 to your computer and use it in GitHub Desktop.
Save bohde/57f4a5295f29ded4bf82 to your computer and use it in GitHub Desktop.
LogEntry Nothing (Variable (Fresh 0)) []
LogEntry Nothing (Spawn 0) []
LogEntry (Just 0) (Variable (Write 0)) [BlockedOn Nothing 0]
LogEntry (Just 0) (Variable (Read 0)) []
LogEntry (Just 0) Halt [BlockedOn Nothing 0]
blocking program
should not block FAILED [1]
Failures:
1) blocking program should not block
predicate failed on: Left [LogEntry Nothing (Variable (Fresh 0)) [],LogEntry Nothing (Spawn 0) [],LogEntry (Just 0) (Variable (Write 0)) [BlockedOn Nothing 0],LogEntry (Just 0) (Variable (Read 0)) [],LogEntry (Just 0) Halt [BlockedOn Nothing 0]] (after 2 tests):
nothing
Randomized with seed 161312233
raceCondition :: MVarM s ()
raceCondition = do
v <- newMVar :: MVarM s (MVar s ())
fork $ do
putMVar v ()
takeMVar v
takeMVar v
main :: IO ()
main = hspec $ do
describe "blocking program" $ do
it "should not block" $ property $ \s -> do
res <- interpret s raceCondition
res `shouldSatisfy` (isRight)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment