mirror of
https://github.com/lexi-lambda/freer-simple.git
synced 2024-12-24 14:43:57 +03:00
Fix randomly failing "Multiple readers work" test
Comparing floating points using (==) is a bad idea. I don't see how this could possible have ever worked. :-/
This commit is contained in:
parent
958dbe0262
commit
ed556f85ad
@ -104,7 +104,7 @@ readerTests = testGroup "Reader tests"
|
|||||||
[ testProperty "Reader passes along environment: n + x"
|
[ testProperty "Reader passes along environment: n + x"
|
||||||
(\n x -> testReader n x == n + x)
|
(\n x -> testReader n x == n + x)
|
||||||
, testProperty "Multiple readers work"
|
, testProperty "Multiple readers work"
|
||||||
(\f n -> testMultiReader f n == ((f + 2.0) + fromIntegral (n + 1)))
|
(\i n -> testMultiReader i n == ((i + 2) + fromIntegral (n + 1)))
|
||||||
, testProperty "Local injects into env"
|
, testProperty "Local injects into env"
|
||||||
(\env inc -> testLocal env inc == 2*(env+1) + inc)
|
(\env inc -> testLocal env inc == 2*(env+1) + inc)
|
||||||
]
|
]
|
||||||
|
@ -28,12 +28,12 @@ t1rr' = run t1
|
|||||||
arising from a use of `t1'
|
arising from a use of `t1'
|
||||||
-}
|
-}
|
||||||
|
|
||||||
testMultiReader :: Float -> Int -> Float
|
testMultiReader :: Integer -> Int -> Integer
|
||||||
testMultiReader f n = run . flip runReader f . flip runReader n $ t2
|
testMultiReader i n = run . flip runReader i . flip runReader n $ t2
|
||||||
where t2 = do
|
where t2 = do
|
||||||
v1 <- ask
|
v1 <- ask
|
||||||
v2 <- ask
|
v2 <- ask
|
||||||
return $ fromIntegral (v1 + (1::Int)) + (v2 + (2::Float))
|
return $ fromIntegral (v1 + (1::Int)) + (v2 + (2::Integer))
|
||||||
|
|
||||||
-- The opposite order of layers
|
-- The opposite order of layers
|
||||||
{- If we mess up, we get an error
|
{- If we mess up, we get an error
|
||||||
|
Loading…
Reference in New Issue
Block a user