diff options
author | Adam Vogt <vogt.adam@gmail.com> | 2014-05-02 20:01:46 +0200 |
---|---|---|
committer | Adam Vogt <vogt.adam@gmail.com> | 2014-05-02 20:01:46 +0200 |
commit | 9660a7a64c749e181d2114cc4b66a8aa4f88be0f (patch) | |
tree | 1664b0ed1ee20f66cf3b7f550c33d49c897bed8c /tests/Properties/Focus.hs | |
parent | b682eaf8fcbb548dacb35b4103e546cbd9fca3ed (diff) | |
download | xmonad-9660a7a64c749e181d2114cc4b66a8aa4f88be0f.tar.gz xmonad-9660a7a64c749e181d2114cc4b66a8aa4f88be0f.tar.xz xmonad-9660a7a64c749e181d2114cc4b66a8aa4f88be0f.zip |
update testsuite (mostly due Jesper Reenberg)
Ignore-this: a5e926aa4e397e70d56e3c9db7108d5b
* use quickcheck2
* run them using cabal's test-suite field
* split up Properties into separate files
darcs-hash:20140502180146-1499c-dc8c09c3ec76a42a0e146925adce960435dc81db.gz
Diffstat (limited to '')
-rw-r--r-- | tests/Properties/Focus.hs | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/tests/Properties/Focus.hs b/tests/Properties/Focus.hs new file mode 100644 index 0000000..865dc72 --- /dev/null +++ b/tests/Properties/Focus.hs @@ -0,0 +1,74 @@ +{-# LANGUAGE ScopedTypeVariables #-} +module Properties.Focus where + +import Test.QuickCheck +import Instances +import Utils + +import XMonad.StackSet hiding (filter) + +import Data.Maybe (fromJust) + +-- --------------------------------------------------------------------- +-- rotating focus +-- + +-- master/focus +-- +-- The tiling order, and master window, of a stack is unaffected by focus changes. +-- +prop_focus_left_master (SizedPositive n) (x::T) = + index (applyN (Just n) focusUp x) == index x +prop_focus_right_master (SizedPositive n) (x::T) = + index (applyN (Just n) focusDown x) == index x +prop_focus_master_master (SizedPositive n) (x::T) = + index (applyN (Just n) focusMaster x) == index x + +prop_focusWindow_master (NonNegative n) (x :: T) = + case peek x of + Nothing -> True + Just _ -> let s = index x + i = n `mod` length s + in index (focusWindow (s !! i) x) == index x + +-- shifting focus is trivially reversible +prop_focus_left (x :: T) = (focusUp (focusDown x)) == x +prop_focus_right (x :: T) = (focusDown (focusUp x)) == x + +-- focus master is idempotent +prop_focusMaster_idem (x :: T) = focusMaster x == focusMaster (focusMaster x) + +-- focusWindow actually leaves the window focused... +prop_focusWindow_works (n :: NonNegative Int) (x :: T) = + case peek x of + Nothing -> True + Just _ -> let s = index x + i = fromIntegral n `mod` length s + in (focus . fromJust . stack . workspace . current) (focusWindow (s !! i) x) == (s !! i) + +-- rotation through the height of a stack gets us back to the start +prop_focus_all_l (x :: T) = (foldr (const focusUp) x [1..n]) == x + where n = length (index x) +prop_focus_all_r (x :: T) = (foldr (const focusDown) x [1..n]) == x + where n = length (index x) + +-- prop_rotate_all (x :: T) = f (f x) == f x +-- f x' = foldr (\_ y -> rotate GT y) x' [1..n] + +-- focus is local to the current workspace +prop_focus_down_local (x :: T) = hidden_spaces (focusDown x) == hidden_spaces x +prop_focus_up_local (x :: T) = hidden_spaces (focusUp x) == hidden_spaces x + +prop_focus_master_local (x :: T) = hidden_spaces (focusMaster x) == hidden_spaces x + +prop_focusWindow_local (n :: NonNegative Int) (x::T ) = + case peek x of + Nothing -> True + Just _ -> let s = index x + i = fromIntegral n `mod` length s + in hidden_spaces (focusWindow (s !! i) x) == hidden_spaces x + +-- On an invalid window, the stackset is unmodified +prop_focusWindow_identity (x::T ) = do + n <- arbitrary `suchThat` \n' -> not $ n' `member` x + return $ focusWindow n x == x |