Added currently unworking test from ticket 4218.
authorRyan Newton <rrnewton@gmail.com>
Tue, 28 Jun 2011 17:44:56 +0000 (13:44 -0400)
committerRyan Newton <rrnewton@gmail.com>
Tue, 28 Jun 2011 17:44:56 +0000 (13:44 -0400)
tests/TestRandomRs.hs [new file with mode: 0644]

diff --git a/tests/TestRandomRs.hs b/tests/TestRandomRs.hs
new file mode 100644 (file)
index 0000000..74e319d
--- /dev/null
@@ -0,0 +1,24 @@
+
+-- Test from ticket #4218:
+-- http://hackage.haskell.org/trac/ghc/ticket/4218
+
+module Main where
+
+import Control.Monad
+import System.Random
+import Data.List
+
+force = foldr (\x r -> x `seq` (x:r)) []
+
+-- Ten million random numbers:
+blowsTheHeap :: IO Integer
+blowsTheHeap = (last . take 10000000 . randomRs (0, 1000000)) `liftM` getStdGen
+
+works :: IO Integer
+works = (last . take 10000000 . force . randomRs (0, 1000000)) `liftM` getStdGen
+
+
+main = 
+ do n <- blowsTheHeap
+    print n
+