[project @ 1999-05-13 11:03:10 by sof]
authorsof <unknown>
Thu, 13 May 1999 11:03:11 +0000 (11:03 +0000)
committersof <unknown>
Thu, 13 May 1999 11:03:11 +0000 (11:03 +0000)
Testing the Random library (not complete).

ghc/tests/lib/should_run/rand001.hs [new file with mode: 0644]
ghc/tests/lib/should_run/rand001.stdout [new file with mode: 0644]

diff --git a/ghc/tests/lib/should_run/rand001.hs b/ghc/tests/lib/should_run/rand001.hs
new file mode 100644 (file)
index 0000000..f514325
--- /dev/null
@@ -0,0 +1,22 @@
+module Main(main) where
+
+import Random
+
+tstRnd rng = checkRange rng (genRnd 50 rng)
+genRnd n rng = take n (randomRs rng (mkStdGen 2))
+checkRange (lo,hi) = all pred
+  where
+   pred
+    | lo <= hi  = \ x -> x >= lo && x <= hi
+    | otherwise = \ x -> x >= hi && x <= lo
+
+main :: IO ()
+main = do
+  print (tstRnd (1,5::Double))
+  print (tstRnd (1,5::Int))
+  print (tstRnd (10,54::Integer))
+  print (tstRnd ((-6),2::Int))
+  print (tstRnd (2,(-6)::Int))
+
diff --git a/ghc/tests/lib/should_run/rand001.stdout b/ghc/tests/lib/should_run/rand001.stdout
new file mode 100644 (file)
index 0000000..2e883c5
--- /dev/null
@@ -0,0 +1,5 @@
+True
+True
+True
+True
+True