From 5c1bb4a2869035308074b1191f8414f6a2287a20 Mon Sep 17 00:00:00 2001 From: Ben Gamari Date: Tue, 15 Oct 2019 16:36:24 -0400 Subject: [PATCH] testsuite: Add test for ghc#16707 --- tests/T16707.hs | 20 ++++++++++++++++++++ tests/all.T | 1 + 2 files changed, 21 insertions(+) create mode 100644 tests/T16707.hs diff --git a/tests/T16707.hs b/tests/T16707.hs new file mode 100644 index 0000000..61e723c --- /dev/null +++ b/tests/T16707.hs @@ -0,0 +1,20 @@ +import Control.Concurrent +import Control.Concurrent.STM +import Debug.Trace + +main :: IO () +main = (`mapM_` [1..1000]) $ \_ -> do + traceEventIO "((((" + + x <- newTVarIO False + + forkIO $ atomically $ writeTVar x True + + traceEventIO "----" + + atomically $ do -- hangs in the second iteration + _ <- readTVar x + writeTVar x True `orElse` return () + + threadDelay 100000 + traceEventIO "))))" diff --git a/tests/all.T b/tests/all.T index c1138fa..2bc0f69 100644 --- a/tests/all.T +++ b/tests/all.T @@ -26,3 +26,4 @@ test('stm065', normal, compile_and_run, ['-package stm']) test('cloneTChan001', normal, compile_and_run, ['-package stm']) test('T15136', extra_run_opts('20'), compile_and_run, ['-package stm']) +test('T16707', normal, compile_and_run, [''])