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).
This commit is contained in:
Platon Pronko
2021-07-15 11:06:37 +03:00
parent da2fb360b8
commit 71e57caa8e
5 changed files with 41 additions and 8 deletions

15
tests/GridSelect.hs Normal file
View File

@@ -0,0 +1,15 @@
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