Merge pull request #33 from thomie/master
[packages/random.git] / tests / TestRandomIOs.hs
1 -- Test for ticket #4218 (TestRandomIOs):
2 -- https://ghc.haskell.org/trac/ghc/ticket/4218
3 --
4 -- Used to fail with:
5 --
6 -- $ cabal test TestRandomIOs --test-options="+RTS -M1M -RTS"
7 -- TestRandomIOs: Heap exhausted;
8
9 module Main where
10
11 import Control.Monad (replicateM)
12 import System.Random (randomIO)
13
14 -- Build a list of 5000 random ints in memory (IO Monad is strict), and print
15 -- the last one.
16 -- Should use less than 1Mb of heap space, or we are generating a list of
17 -- unevaluated thunks.
18 main = do
19 rs <- replicateM 5000 randomIO :: IO [Int]
20 print $ last rs