[commit: random] master: Extended rangeTest to handle some more corner cases. (6d60652)
Ian Lynagh
igloo at earth.li
Fri Jul 8 18:47:37 CEST 2011
Repository : ssh://darcs.haskell.org//srv/darcs/packages/random
On branch : master
http://hackage.haskell.org/trac/ghc/changeset/6d60652bd0801efdb55822227996afe94b9b444b
>---------------------------------------------------------------
commit 6d60652bd0801efdb55822227996afe94b9b444b
Author: Ryan Newton <rrnewton at gmail.com>
Date: Tue Jun 28 01:06:21 2011 -0400
Extended rangeTest to handle some more corner cases.
>---------------------------------------------------------------
tests/rangeTest.hs | 14 ++++++++------
tests/rangeTest.stdout | 3 +++
2 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/tests/rangeTest.hs b/tests/rangeTest.hs
index a9fbf12..ec95e56 100644
--- a/tests/rangeTest.hs
+++ b/tests/rangeTest.hs
@@ -26,11 +26,9 @@ approxBounds nxt iters unused (explo,exphi) initrng =
-- (1) all generated numbers are in bounds
-- (2) we get "close" to the bounds
-- The with (2) is that we do enough trials to ensure that we can at
--- least hit the 95% mark.
-
---checkBounds:: (Fractional a, Ord a) =>
---checkBounds:: (Real a, Ord a) =>
--- String -> (Bool, a, a) -> (StdGen -> ((a, a, t), StdGen)) -> IO ()
+-- least hit the 90% mark.
+checkBounds:: (Real a, Ord a) =>
+ String -> (Bool, a, a) -> ((a,a) -> StdGen -> ((a, a, t), StdGen)) -> IO ()
checkBounds msg (exclusive,lo,hi) fun =
-- (lo,hi) is [inclusive,exclusive)
do putStr$ msg
@@ -53,7 +51,7 @@ intRange bits = ( False, 0 - x - x, x - 1 + x)
wordRange bits = ( False, 0, x - 1 + x )
where x = 2 ^ (bits-1)
-trials = 10000
+trials = 5000
nb = bitSize (0::Int) -- Native bits
main =
@@ -96,6 +94,10 @@ main =
checkBounds "Int R" (False,-100,100) (approxBounds (randomR (-100,100)) trials (undefined::Int))
checkBounds "Integer R" (False,-100,100) (approxBounds (randomR (-100,100)) trials (undefined::Integer))
checkBounds "Int8 R" (False,-100,100) (approxBounds (randomR (-100,100)) trials (undefined::Int8))
+ checkBounds "Int8 Rsmall" (False,-50,50) (approxBounds (randomR (-50,50)) trials (undefined::Int8))
+ checkBounds "Int8 Rmini" (False,3,4) (approxBounds (randomR (3,4)) trials (undefined::Int8))
+ checkBounds "Int8 Rtrivial" (False,3,3) (approxBounds (randomR (3,3)) trials (undefined::Int8))
+
checkBounds "Int16 R" (False,-100,100) (approxBounds (randomR (-100,100)) trials (undefined::Int16))
checkBounds "Int32 R" (False,-100,100) (approxBounds (randomR (-100,100)) trials (undefined::Int32))
checkBounds "Int64 R" (False,-100,100) (approxBounds (randomR (-100,100)) trials (undefined::Int64))
diff --git a/tests/rangeTest.stdout b/tests/rangeTest.stdout
index 379f3c0..55ccaff 100644
--- a/tests/rangeTest.stdout
+++ b/tests/rangeTest.stdout
@@ -33,6 +33,9 @@ CUIntMax: Passed
Int R: Passed
Integer R: Passed
Int8 R: Passed
+Int8 Rsmall: Passed
+Int8 Rmini: Passed
+Int8 Rtrivial: Passed
Int16 R: Passed
Int32 R: Passed
Int64 R: Passed
More information about the Cvs-libraries
mailing list