Merge pull request #33 from thomie/master
[packages/random.git] / tests / TestRandomRs.hs
1 -- Test for ticket #4218 (TestRandomRs):
2 -- https://ghc.haskell.org/trac/ghc/ticket/4218
3 --
4 -- Fixed together with ticket #8704
5 -- https://ghc.haskell.org/trac/ghc/ticket/8704
6 -- Commit 4695ffa366f659940369f05e419a4f2249c3a776
7 --
8 -- Used to fail with:
9 --
10 -- $ cabal test TestRandomRs --test-options="+RTS -M1M -RTS"
11 -- TestRandomRs: Heap exhausted;
12
13 module Main where
14
15 import Control.Monad (liftM, replicateM)
16 import System.Random (randomRs, getStdGen)
17
18 -- Return the five-thousandth random number:
19 -- Should run in constant space (< 1Mb heap).
20 main = do
21 n <- (last . take 5000 . randomRs (0, 1000000)) `liftM` getStdGen
22 print (n::Integer)