Skip to content

Commit

Permalink
Add basic property test for shuffleList
Browse files Browse the repository at this point in the history
  • Loading branch information
lehins committed Jan 27, 2024
1 parent 043f82b commit 4d212cc
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions test/Spec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import Control.Monad.ST (runST)
import qualified Data.ByteString as BS
import qualified Data.ByteString.Short as SBS
import Data.Int
import Data.List (sortOn)
import Data.Typeable
import Data.Void
import Data.Word
Expand Down Expand Up @@ -245,6 +246,12 @@ uniformSpec px =
case uniform g of
(range, g') ->
take len (randomRs range g' :: [a]) == fst (uniformListR len range g')
, SC.testProperty "shuffleList" $
seededWithLen $ \len g ->
case uniformList len g of
(xs, g') ->
let xs' = zip [0 :: Int ..] (xs :: [a])
in sortOn fst (fst (shuffleList xs' g')) == xs'
, SC.testProperty "uniforms" $
seededWithLen $ \len g ->
take len (randoms g :: [a]) == take len (uniforms g)
Expand Down

0 comments on commit 4d212cc

Please sign in to comment.