@@ -126,13 +126,21 @@ integralSpec px =
126126
127127floatingSpec ::
128128 forall a .
129- (SC. Serial IO a , Typeable a , Num a , Ord a , Random a , UniformRange a , Show a )
129+ (SC. Serial IO a , Typeable a , Num a , Ord a , Random a , UniformRange a , Read a , Show a )
130130 => Proxy a -> TestTree
131131floatingSpec px =
132132 testGroup (" (" ++ showsType px " )" )
133133 [ SC. testProperty " uniformR" $ seeded $ Range. uniformRangeWithin px
134+ , testCase " r = +inf, x = 0" $ positiveInf @?= fst (uniformR (0 , positiveInf) (ConstGen 0 ))
135+ , testCase " r = +inf, x = 1" $ positiveInf @?= fst (uniformR (0 , positiveInf) (ConstGen 1 ))
136+ , testCase " l = -inf, x = 0" $ negativeInf @?= fst (uniformR (negativeInf, 0 ) (ConstGen 0 ))
137+ , testCase " l = -inf, x = 1" $ negativeInf @?= fst (uniformR (negativeInf, 0 ) (ConstGen 1 ))
134138 -- TODO: Add more tests
135139 ]
140+ where
141+ positiveInf , negativeInf :: a
142+ positiveInf = read " Infinity"
143+ negativeInf = read " -Infinity"
136144
137145runSpec :: TestTree
138146runSpec = testGroup " runGenState_ and runPrimGenIO_"
@@ -141,3 +149,9 @@ runSpec = testGroup "runGenState_ and runPrimGenIO_"
141149-- | Create a StdGen instance from an Int and pass it to the given function.
142150seeded :: (StdGen -> a ) -> Int -> a
143151seeded f = f . mkStdGen
152+
153+ newtype ConstGen = ConstGen Word64
154+
155+ instance RandomGen ConstGen where
156+ genWord64 g@ (ConstGen c) = (c, g)
157+ split g = (g, g)
0 commit comments