Skip to content

Commit d23fc1e

Browse files
committed
Update Char usage for Int changes
1 parent 01711a1 commit d23fc1e

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

src/Test/QuickCheck/Arbitrary.purs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ instance arbString :: Arbitrary String where
5454
arbitrary = fromCharArray <$> arbitrary
5555

5656
instance coarbString :: CoArbitrary String where
57-
coarbitrary s = coarbitrary $ (charCodeAt 0 <$> split "" s)
57+
coarbitrary s = coarbitrary $ (charCodeAt zero <$> split "" s)
5858

5959
instance arbChar :: Arbitrary Char where
60-
arbitrary = fromCharCode <<< ((*) 65535) <$> uniform
60+
arbitrary = fromCharCode <<< fromNumber <<< (* 65535) <$> uniform
6161

6262
instance coarbChar :: CoArbitrary Char where
6363
coarbitrary c = coarbitrary $ toCharCode c

src/Test/QuickCheck/Data/AlphaNumString.purs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
module Test.QuickCheck.Data.AlphaNumString where
22

3+
import Data.Int (fromNumber, toNumber)
34
import Data.String (fromCharArray, length)
45
import Data.String.Unsafe (charAt)
56
import Math (round)
@@ -12,11 +13,12 @@ newtype AlphaNumString = AlphaNumString String
1213
instance 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

2123
instance coarbAlphaNumString :: CoArbitrary AlphaNumString where
2224
coarbitrary (AlphaNumString s) = coarbitrary s

0 commit comments

Comments
 (0)