Add some simple tests

This commit is contained in:
Harendra Kumar 2017-08-07 15:14:41 +05:30
parent c49732a7a6
commit 11c1f14755

View File

@ -11,8 +11,18 @@ default (Int)
main :: IO ()
main = hspec $ do
it "simple wait_" $
wait_ (return 0) `shouldReturn` ()
it "simple wait_ with IO" $
wait_ (liftIO $ putStrLn "hello") `shouldReturn` ()
it "Captures a return value using wait" $
wait (return 0) `shouldReturn` ([0] :: [Int])
it "simple wait_ and 'then' with IO" $
wait_ (liftIO (putStrLn "hello") >> liftIO (putStrLn "world")) `shouldReturn` ()
it "Then and wait" $
wait (return 1 >> return 2) `shouldReturn` ([2] :: [Int])
it "Bind and wait" $
wait (do x <- return 1; y <- return 2; return (x + y)) `shouldReturn` ([3] :: [Int])
it "Alternative composition of sync tasks" $
((wait $ threads 0 $ (return 0 <|> return 1)) >>= return . sort) `shouldReturn` ([0, 1] :: [Int])
it "Alternative composition of async and sync tasks" $