File tree Expand file tree Collapse file tree 5 files changed +16
-3
lines changed Expand file tree Collapse file tree 5 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -100,6 +100,8 @@ instance showResult :: Show Result
100
100
(<?>) :: Boolean -> String -> Result
101
101
```
102
102
103
+ _ left-associative / precedence -1_
104
+
103
105
This operator attaches an error message to a failed test.
104
106
105
107
For example:
@@ -114,6 +116,8 @@ test x = myProperty x <?> ("myProperty did not hold for " <> show x)
114
116
(===) :: forall a b. (Eq a, Show a) => a -> a -> Result
115
117
```
116
118
119
+ _ left-associative / precedence -1_
120
+
117
121
Self-documenting equality assertion
118
122
119
123
#### ` (/==) `
@@ -122,6 +126,8 @@ Self-documenting equality assertion
122
126
(/==) :: forall a b. (Eq a, Show a) => a -> a -> Result
123
127
```
124
128
129
+ _ left-associative / precedence -1_
130
+
125
131
Self-documenting inequality assertion
126
132
127
133
Original file line number Diff line number Diff line change @@ -29,4 +29,6 @@ instance numApproxNumber :: Num ApproxNumber
29
29
(=~=) :: Number -> Number -> Boolean
30
30
```
31
31
32
+ _ left-associative / precedence -1_
33
+
32
34
Original file line number Diff line number Diff line change @@ -44,4 +44,6 @@ Step the linear congruential generator
44
44
randomSeed :: forall e. Eff (random :: RANDOM | e) Seed
45
45
```
46
46
47
+ Create a random seed
48
+
47
49
Original file line number Diff line number Diff line change @@ -46,14 +46,14 @@ quickCheck' n prop = do
46
46
seed <- randomSeed
47
47
let results = quickCheckPure seed n prop
48
48
let successes = countSuccesses results
49
- log $ show (toNumber successes) ++ " /" ++ show (toNumber n) ++ " test(s) passed."
49
+ log $ show successes ++ " /" ++ show n ++ " test(s) passed."
50
50
throwOnFirstFailure one results
51
51
52
52
where
53
53
54
54
throwOnFirstFailure :: Int -> List Result -> QC Unit
55
55
throwOnFirstFailure _ Nil = return unit
56
- throwOnFirstFailure n (Cons (Failed msg) _) = throwException $ error $ " Test " ++ show (toNumber n) ++ " failed: \n " ++ msg
56
+ throwOnFirstFailure n (Cons (Failed msg) _) = throwException $ error $ " Test " ++ show n ++ " failed: \n " ++ msg
57
57
throwOnFirstFailure n (Cons _ rest) = throwOnFirstFailure (n + one) rest
58
58
59
59
countSuccesses :: List Result -> Int
Original file line number Diff line number Diff line change @@ -9,10 +9,12 @@ module Test.QuickCheck.LCG
9
9
10
10
import Prelude
11
11
12
+ import Math ((%))
12
13
import Control.Monad.Eff (Eff ())
13
14
import Control.Monad.Eff.Random (RANDOM (), randomInt )
14
15
import Data.Int (fromNumber , toNumber )
15
16
import Data.Int.Bits (shl )
17
+ import qualified Data.Maybe.Unsafe as U
16
18
17
19
type Seed = Int
18
20
@@ -30,7 +32,8 @@ lcgN = one `shl` 30
30
32
31
33
-- | Step the linear congruential generator
32
34
lcgNext :: Int -> Int
33
- lcgNext n = ( lcgM * n + lcgC) `mod` lcgN
35
+ lcgNext n = U .fromJust $ fromNumber $ (toNumber lcgM * toNumber n + toNumber lcgC) % toNumber lcgN
34
36
37
+ -- | Create a random seed
35
38
randomSeed :: forall e . Eff (random :: RANDOM | e ) Seed
36
39
randomSeed = randomInt 0 lcgM
You can’t perform that action at this time.
0 commit comments