File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -54,10 +54,10 @@ instance arbString :: Arbitrary String where
5454 arbitrary = fromCharArray <$> arbitrary
5555
5656instance coarbString :: CoArbitrary String where
57- coarbitrary s = coarbitrary $ (charCodeAt 0 <$> split " " s)
57+ coarbitrary s = coarbitrary $ (charCodeAt zero <$> split " " s)
5858
5959instance arbChar :: Arbitrary Char where
60- arbitrary = fromCharCode <<< ((*) 65535 ) <$> uniform
60+ arbitrary = fromCharCode <<< fromNumber <<< (* 65535 ) <$> uniform
6161
6262instance coarbChar :: CoArbitrary Char where
6363 coarbitrary c = coarbitrary $ toCharCode c
Original file line number Diff line number Diff line change 11module Test.QuickCheck.Data.AlphaNumString where
22
3+ import Data.Int (fromNumber , toNumber )
34import Data.String (fromCharArray , length )
45import Data.String.Unsafe (charAt )
56import Math (round )
@@ -12,11 +13,12 @@ newtype AlphaNumString = AlphaNumString String
1213instance arbAlphaNumString :: Arbitrary AlphaNumString where
1314 arbitrary = do
1415 arrNum <- arbitrary
15- return $ AlphaNumString <<< fromCharArray $ lookup <$> arrNum where
16- chars = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
16+ return $ AlphaNumString <<< fromCharArray $ lookup <$> arrNum
17+ where
18+ chars = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
19+ lookup x = let index = fromNumber $ x * (toNumber (length chars) - 1 )
20+ in charAt index chars
1721
18- lookup x = charAt index chars where
19- index = round $ x * (length chars - 1 )
2022
2123instance coarbAlphaNumString :: CoArbitrary AlphaNumString where
2224 coarbitrary (AlphaNumString s) = coarbitrary s
You can’t perform that action at this time.
0 commit comments