diff options
author | Don Stewart <dons@cse.unsw.edu.au> | 2007-04-30 07:57:51 +0200 |
---|---|---|
committer | Don Stewart <dons@cse.unsw.edu.au> | 2007-04-30 07:57:51 +0200 |
commit | 4a9ace968e790f91fcd0093e283bdfa2fb6a6328 (patch) | |
tree | 87a0ed3dff44f6dd995e6b0f124b1c0253d61fc6 | |
parent | cab40b32e3a0bfe3e78b12807352dc9635329c5d (diff) | |
download | metatile-4a9ace968e790f91fcd0093e283bdfa2fb6a6328.tar metatile-4a9ace968e790f91fcd0093e283bdfa2fb6a6328.zip |
add rotate all and view idempotency tests
darcs-hash:20070430055751-9c5c1-da5da09a5c2ff160fb7b243794d5fd3d7f954cb1
-rw-r--r-- | tests/Properties.hs | 22 |
1 files changed, 19 insertions, 3 deletions
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) |