cfuture-2.0: test/HsTestCase.hs
-- We call this from main.c.
module HsTestCase (hsTestCase) where
import Control.Concurrent.CFuture
import Control.Concurrent (threadDelay)
import OurTasks
-- | Called from main.c.
hsTestCase :: IO Bool
hsTestCase = do
print "Working"
future <- forkFuture task
print "Delay"
threadDelay 2000000
_ <- abort future
print "Aborted"
result <- get future
-- it should be an exception
case result of
Nothing -> return True -- the expected result
_ -> return False
foreign export ccall hsTestCase :: IO Bool