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:
Tomas Janousek 2017-01-28 12:57:31 +01:00
parent 958dbe0262
commit ed556f85ad
2 changed files with 4 additions and 4 deletions

View File

@ -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)
] ]

View File

@ -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