From 9660a7a64c749e181d2114cc4b66a8aa4f88be0f Mon Sep 17 00:00:00 2001 From: Adam Vogt Date: Fri, 2 May 2014 20:01:46 +0200 Subject: 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 --- tests/Properties/Focus.hs | 74 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 tests/Properties/Focus.hs (limited to 'tests/Properties/Focus.hs') 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 -- cgit v1.2.3