aboutsummaryrefslogtreecommitdiffstats
path: root/tests/Utils.hs
diff options
context:
space:
mode:
authorAdam Vogt <vogt.adam@gmail.com>2014-05-07 04:49:30 +0200
committerAdam Vogt <vogt.adam@gmail.com>2014-05-07 04:49:30 +0200
commit77983153f9e891f1199c8faa16dcb2a0e8bcbbb9 (patch)
tree000f6d063c9f82a401550c58f2540836995aed6f /tests/Utils.hs
parentf9cef5a2c4fe643f2d2230e3f027e8c9884c7cdb (diff)
downloadxmonad-77983153f9e891f1199c8faa16dcb2a0e8bcbbb9.tar.gz
xmonad-77983153f9e891f1199c8faa16dcb2a0e8bcbbb9.tar.xz
xmonad-77983153f9e891f1199c8faa16dcb2a0e8bcbbb9.zip
make the check for overflow cleaner
Ignore-this: c12448f9219c8a29f2707526691acfda darcs-hash:20140507024930-1499c-52860fb59794c3f370f27158b0936f845fce6ded.gz
Diffstat (limited to 'tests/Utils.hs')
-rw-r--r--tests/Utils.hs10
1 files changed, 9 insertions, 1 deletions
diff --git a/tests/Utils.hs b/tests/Utils.hs
index 2d9df81..e3eef0f 100644
--- a/tests/Utils.hs
+++ b/tests/Utils.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE RankNTypes #-}
module Utils where
import XMonad.StackSet hiding (filter)
@@ -35,5 +36,12 @@ applyN Nothing f v = v
applyN (Just 0) f v = v
applyN (Just n) f v = applyN (Just $ n-1) f (f v)
-
tags x = map tag $ workspaces x
+
+
+-- | noOverflows op a b is True if @a `op` fromIntegral b@ overflows (or
+-- otherwise gives the same answer when done using Integer
+noOverflows :: (Integral b, Integral c) =>
+ (forall a. Integral a => a -> a -> a) -> b -> c -> Bool
+noOverflows op a b = toInteger (a `op` fromIntegral b) == toInteger a `op` toInteger b
+