diff --git a/splitmix.cabal b/splitmix.cabal index 4cd8f2a..a5c70d8 100644 --- a/splitmix.cabal +++ b/splitmix.cabal @@ -125,6 +125,7 @@ test-suite examples build-depends: base , HUnit ==1.3.1.2 || >=1.6.0.0 && <1.7 + , random , splitmix test-suite montecarlo-pi diff --git a/tests/Examples.hs b/tests/Examples.hs index 0c8e00c..2a6d92c 100644 --- a/tests/Examples.hs +++ b/tests/Examples.hs @@ -2,6 +2,8 @@ module Main (main) where import Test.HUnit ((@?=)) +import qualified System.Random as R +import qualified System.Random.SplitMix as SM import qualified System.Random.SplitMix32 as SM32 main :: IO () @@ -13,3 +15,19 @@ main = do let (w32, g') = SM32.nextWord32 g w32 @?= 1296549791 show g' @?= "SMGen 1747133669 1604540297" + + issue23 + +issue23 :: IO () +issue23 = do + let seed = (10000, 10000) + let (txt, g) = populateRandomString (SM.seedSMGen' seed) + txt @?= "QH" + print g + + where + populateRandomString :: SM.SMGen -> (String, SM.SMGen) + populateRandomString smGen = + let (char, ngen) = R.randomR ('A', 'Z') smGen + (char2, gen2) = R.randomR ('A', 'Z') ngen + in ([char, char2], gen2)