mirror of
https://github.com/GaloisInc/cryptol.git
synced 2025-01-04 22:03:11 +03:00
Use tf-random for higher-quality randoms.
Notice the randoms from StdGen are well-known to be quite bad. For example, see comments in issue #86.
This commit is contained in:
parent
a0bb572388
commit
a2fbf632f5
@ -37,6 +37,7 @@ library
|
|||||||
process >= 1.2,
|
process >= 1.2,
|
||||||
QuickCheck >= 2.7,
|
QuickCheck >= 2.7,
|
||||||
random >= 1.0.1,
|
random >= 1.0.1,
|
||||||
|
tf-random >= 0.5,
|
||||||
smtLib >= 1.0.7,
|
smtLib >= 1.0.7,
|
||||||
syb >= 0.4,
|
syb >= 0.4,
|
||||||
text >= 1.1,
|
text >= 1.1,
|
||||||
@ -179,6 +180,7 @@ executable cryptol
|
|||||||
monadLib,
|
monadLib,
|
||||||
process,
|
process,
|
||||||
random,
|
random,
|
||||||
|
tf-random,
|
||||||
transformers
|
transformers
|
||||||
GHC-options: -Wall -O2
|
GHC-options: -Wall -O2
|
||||||
|
|
||||||
@ -202,6 +204,7 @@ executable cryptolnb
|
|||||||
monadLib,
|
monadLib,
|
||||||
process,
|
process,
|
||||||
random,
|
random,
|
||||||
|
tf-random,
|
||||||
transformers
|
transformers
|
||||||
GHC-options: -Wall -O2
|
GHC-options: -Wall -O2
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ import System.Directory(getHomeDirectory,setCurrentDirectory,doesDirectoryExist)
|
|||||||
import qualified Data.Map as Map
|
import qualified Data.Map as Map
|
||||||
import qualified Data.IntMap as IntMap
|
import qualified Data.IntMap as IntMap
|
||||||
import System.IO(hFlush,stdout)
|
import System.IO(hFlush,stdout)
|
||||||
import System.Random(newStdGen)
|
import System.Random.TF(newTFGen)
|
||||||
import Numeric (showFFloat)
|
import Numeric (showFFloat)
|
||||||
|
|
||||||
#if __GLASGOW_HASKELL__ < 706
|
#if __GLASGOW_HASKELL__ < 706
|
||||||
@ -266,7 +266,7 @@ qcCmd str =
|
|||||||
Just gens ->
|
Just gens ->
|
||||||
do io $ putStrLn "Using random testing."
|
do io $ putStrLn "Using random testing."
|
||||||
prt testingMsg
|
prt testingMsg
|
||||||
g <- io newStdGen
|
g <- io newTFGen
|
||||||
ok <- go (TestR.runTest val gens) testNum 0 g
|
ok <- go (TestR.runTest val gens) testNum 0 g
|
||||||
when ok $
|
when ok $
|
||||||
case n of
|
case n of
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
-- Portability : portable
|
-- Portability : portable
|
||||||
|
|
||||||
{-# LANGUAGE CPP #-}
|
{-# LANGUAGE CPP #-}
|
||||||
{-# LANGUAGE Safe #-}
|
{-# LANGUAGE Trustworthy #-}
|
||||||
{-# LANGUAGE TupleSections #-}
|
{-# LANGUAGE TupleSections #-}
|
||||||
{-# LANGUAGE Rank2Types #-}
|
{-# LANGUAGE Rank2Types #-}
|
||||||
{-# LANGUAGE PatternGuards #-}
|
{-# LANGUAGE PatternGuards #-}
|
||||||
@ -30,7 +30,7 @@ import Data.List (sortBy,transpose,genericTake,genericReplicate,genericSplitAt)
|
|||||||
import Data.Ord (comparing)
|
import Data.Ord (comparing)
|
||||||
import Data.Bits (Bits(..))
|
import Data.Bits (Bits(..))
|
||||||
|
|
||||||
import System.Random (mkStdGen)
|
import System.Random.TF (mkTFGen)
|
||||||
|
|
||||||
|
|
||||||
-- Utilities -------------------------------------------------------------------
|
-- Utilities -------------------------------------------------------------------
|
||||||
@ -767,7 +767,7 @@ randomV :: TValue -> Integer -> Value
|
|||||||
randomV ty seed =
|
randomV ty seed =
|
||||||
case randomValue (tValTy ty) of
|
case randomValue (tValTy ty) of
|
||||||
Nothing -> zeroV ty
|
Nothing -> zeroV ty
|
||||||
Just gen -> fst $ gen 100 $ mkStdGen (fromIntegral seed)
|
Just gen -> fst $ gen 100 $ mkTFGen (fromIntegral seed)
|
||||||
|
|
||||||
|
|
||||||
-- Miscellaneous ---------------------------------------------------------------
|
-- Miscellaneous ---------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user