xmonad-contrib/tests/GridSelect.hs
Platon Pronko 71e57caa8e rewrite GridSelect.stringToRatio to use randomR (fixes #572)
Due to differences between random-1.1 and random-1.2, on newer systems
stringToRatio returns numbers outside [0, 1] range, which breaks
colorRangeFromClassName colorizers.

This commit fixes the issue by using randomR to directly generate the random number.

Also this fixes the compilation warning (genRange and next are deprecated in random-1.2).
2021-07-19 21:20:40 +03:00

16 lines
343 B
Haskell

module GridSelect where
import Test.Hspec
import Test.Hspec.QuickCheck
import XMonad.Actions.GridSelect
spec :: Spec
spec = do
prop "prop_stringToRatio_valuesInRange" prop_stringToRatio_valuesInRange
prop_stringToRatio_valuesInRange :: String -> Bool
prop_stringToRatio_valuesInRange s =
let r = stringToRatio s
in r >= 0 && r <= 1