diff options
author | Ben Gamari <ben@smart-cactus.org> | 2021-02-21 19:26:51 -0500 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-03-04 23:15:12 -0500 |
commit | c6ec7f4868cd7b22869f559de23acd3245639c68 (patch) | |
tree | a61b92a6efd5c2ac29473acd02eb9e8b7524b78b /testsuite | |
parent | e679321e859d2acad2248249efaab9bf1c13521b (diff) | |
download | haskell-c6ec7f4868cd7b22869f559de23acd3245639c68.tar.gz |
testsuite: Add test for #19413
This was fixed as a result of #19181.
Diffstat (limited to 'testsuite')
-rw-r--r-- | testsuite/tests/simplCore/should_run/T19413.hs | 17 | ||||
-rw-r--r-- | testsuite/tests/simplCore/should_run/T19413.stdout | 2 | ||||
-rw-r--r-- | testsuite/tests/simplCore/should_run/all.T | 1 |
3 files changed, 20 insertions, 0 deletions
diff --git a/testsuite/tests/simplCore/should_run/T19413.hs b/testsuite/tests/simplCore/should_run/T19413.hs new file mode 100644 index 0000000000..65727e4e76 --- /dev/null +++ b/testsuite/tests/simplCore/should_run/T19413.hs @@ -0,0 +1,17 @@ +{-# OPTIONS_GHC -O1 #-} + +import System.IO.Unsafe +import Data.IORef + +{-# NOINLINE resourceId #-} +resourceId :: IO Int +resourceId = unsafePerformIO counter + +counter :: IO (IO Int) +counter = do + ref <- newIORef 0 + pure $ atomicModifyIORef' ref $ \i -> let j = i + 1 in (j, j) + +main = do + print =<< resourceId + print =<< resourceId diff --git a/testsuite/tests/simplCore/should_run/T19413.stdout b/testsuite/tests/simplCore/should_run/T19413.stdout new file mode 100644 index 0000000000..1191247b6d --- /dev/null +++ b/testsuite/tests/simplCore/should_run/T19413.stdout @@ -0,0 +1,2 @@ +1 +2 diff --git a/testsuite/tests/simplCore/should_run/all.T b/testsuite/tests/simplCore/should_run/all.T index afedee6bcc..a6458ee311 100644 --- a/testsuite/tests/simplCore/should_run/all.T +++ b/testsuite/tests/simplCore/should_run/all.T @@ -97,3 +97,4 @@ test('NumConstantFolding8', normal, compile_and_run, ['']) test('NumConstantFolding16', normal, compile_and_run, ['']) test('NumConstantFolding32', normal, compile_and_run, ['']) test('NumConstantFolding', normal, compile_and_run, ['']) +test('T19413', normal, compile_and_run, ['']) |