summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSpencer Janssen <sjanssen@cse.unl.edu>2007-08-15 04:55:04 +0200
committerSpencer Janssen <sjanssen@cse.unl.edu>2007-08-15 04:55:04 +0200
commit215b5fabba19875f9032d7ce7bf33c0291149b47 (patch)
tree7cc5a80ee012da44d0277a82283047fcaec9b73b /tests
parent649dfb57a92e579859fb2d85f85ba961333fdd17 (diff)
downloadmetatile-215b5fabba19875f9032d7ce7bf33c0291149b47.tar
metatile-215b5fabba19875f9032d7ce7bf33c0291149b47.zip
Add greedyView, make it the default action for mod-wer
darcs-hash:20070815025504-a5988-00ff316a056c48cc07c5e90925702d2ac09ae666
Diffstat (limited to 'tests')
-rw-r--r--tests/Properties.hs36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/Properties.hs b/tests/Properties.hs
index 589275a..e11b448 100644
--- a/tests/Properties.hs
+++ b/tests/Properties.hs
@@ -136,6 +136,9 @@ prop_empty_I (n :: Positive Int) = forAll (choose (1,fromIntegral n)) $ \m ->
prop_view_I (n :: NonNegative Int) (x :: T) =
n `tagMember` x ==> invariant $ view (fromIntegral n) x
+prop_greedyView_I (n :: NonNegative Int) (x :: T) =
+ n `tagMember` x ==> invariant $ view (fromIntegral n) x
+
prop_focusUp_I (n :: NonNegative Int) (x :: T) =
invariant $ foldr (const focusUp) x [1..n]
prop_focusDown_I (n :: NonNegative Int) (x :: T) =
@@ -217,6 +220,33 @@ prop_view_reversible (i :: NonNegative Int) (x :: T) =
i `tagMember` x ==> normal (view n (view i x)) == normal x
where n = tag (workspace $ current x)
+-- ---------------------------------------------------------------------
+-- greedyViewing workspaces
+
+-- greedyView sets the current workspace to 'n'
+prop_greedyView_current (x :: T) (n :: NonNegative Int) = i `tagMember` x ==>
+ tag (workspace $ current (greedyView i x)) == i
+ where
+ i = fromIntegral n
+
+-- greedyView *only* sets the current workspace, and touches Xinerama.
+-- no workspace contents will be changed.
+prop_greedyView_local (x :: T) (n :: NonNegative Int) = i `tagMember` x ==>
+ workspaces x == workspaces (greedyView i x)
+ where
+ workspaces a = sortBy (\s t -> tag s `compare` tag t) $
+ workspace (current a)
+ : map workspace (visible a) ++ hidden a
+ i = fromIntegral n
+
+-- greedyView is idempotent
+prop_greedyView_idem (x :: T) (i :: NonNegative Int) = i `tagMember` x ==> greedyView i (greedyView i x) == (greedyView i x)
+
+-- greedyView is reversible, though shuffles the order of hidden/visible
+prop_greedyView_reversible (i :: NonNegative Int) (x :: T) =
+ i `tagMember` x ==> normal (greedyView n (greedyView i x)) == normal x
+ where n = tag (workspace $ current x)
+
-- normalise workspace list
normal s = s { hidden = sortBy g (hidden s), visible = sortBy f (visible s) }
where
@@ -518,6 +548,12 @@ main = do
-- ,("view / xinerama" , mytest prop_view_xinerama)
,("view is local" , mytest prop_view_local)
+ ,("greedyView : invariant" , mytest prop_greedyView_I)
+ ,("greedyView sets current" , mytest prop_greedyView_current)
+ ,("greedyView idempotent" , mytest prop_greedyView_idem)
+ ,("greedyView reversible" , mytest prop_greedyView_reversible)
+ ,("greedyView is local" , mytest prop_greedyView_local)
+--
-- ,("valid workspace xinerama", mytest prop_lookupWorkspace)
,("peek/member " , mytest prop_member_peek)