From 4a9ace968e790f91fcd0093e283bdfa2fb6a6328 Mon Sep 17 00:00:00 2001 From: Don Stewart Date: Mon, 30 Apr 2007 07:57:51 +0200 Subject: add rotate all and view idempotency tests darcs-hash:20070430055751-9c5c1-da5da09a5c2ff160fb7b243794d5fd3d7f954cb1 --- tests/Properties.hs | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/Properties.hs b/tests/Properties.hs index d8b0a48..b49cbd3 100644 --- a/tests/Properties.hs +++ b/tests/Properties.hs @@ -119,8 +119,15 @@ prop_delete2 i x = prop_focus1 i x = member i x ==> peek (raiseFocus i x) == Just i where _ = x :: T -prop_rotaterotate x = rotate LT (rotate GT x) == x - where _ = x :: T +-- rotation is reversible in two directions +prop_rotaterotate1 (x :: T) = rotate LT (rotate GT x) == x +prop_rotaterotate2 (x :: T) = rotate GT (rotate LT x) == x + +-- rotation through the height of a stack gets us back to the start +prop_rotate_all (x :: T) = foldr (\_ y -> rotate GT y) x [1..n] == x + where + n = height (current x) x + prop_viewview r x = let n = current x @@ -130,6 +137,11 @@ prop_viewview r x = where _ = x :: T +prop_view_idem (x :: T) r = + let i = fromIntegral $ r `mod` sz + sz = size x + in view i (view i x) == (view i x) + prop_shiftshift r x = let n = current x in shift n (shift r x) == x @@ -304,9 +316,13 @@ main = do ,("focus", mytest prop_focus1) - ,("rotate/rotate ", mytest prop_rotaterotate) + ,("rotate l >> rotate r", mytest prop_rotaterotate1) + ,("rotate r >> rotate l", mytest prop_rotaterotate2) + ,("rotate all", mytest prop_rotate_all) ,("view/view ", mytest prop_viewview) + ,("view idem ", mytest prop_view_idem) + ,("fullcache ", mytest prop_fullcache) ,("currentwsvisible ", mytest prop_currentwsvisible) ,("ws screen mapping", mytest prop_ws2screen_screen2ws) -- cgit v1.2.3