4 import Control.Monad (liftM, liftM2)
5 import Prelude hiding (LT)
12 instance Arbitrary Cardinal where
13 arbitrary = oneof [f,b,l,r,d,t,fl,fr,fd,ft,bl,br,bd,bt,ld,lt,
14 rd,rt,fld,flt,frd,frt,bld,blt,brd,brt,i,
15 scalar,csum,cdiff,cprod,cquot]
44 scalar = liftM Scalar arbitrary
45 csum = liftM2 Sum arbitrary arbitrary
46 cdiff = liftM2 Difference arbitrary arbitrary
47 cprod = liftM2 Product arbitrary arbitrary
48 cquot = liftM2 Quotient arbitrary arbitrary
51 prop_ccwx_rotation_changes_direction :: Cardinal -> Property
52 prop_ccwx_rotation_changes_direction c =
53 -- The front and back faces are unchanged by x-rotation.
54 c `elem` [L, R, D, T, FL, FR, FD, FT, BL, BR, BD, BT, LD, LT,
55 RD, RT, FLD, FLT, FRD, FRT, BLD, BLT, BRD, BRT]
58 prop_cwx_rotation_changes_direction :: Cardinal -> Property
59 prop_cwx_rotation_changes_direction c =
60 -- The front and back faces are unchanged by x-rotation.
61 c `elem` [L, R, D, T, FL, FR, FD, FT, BL, BR, BD, BT, LD, LT,
62 RD, RT, FLD, FLT, FRD, FRT, BLD, BLT, BRD, BRT]
65 -- | If you rotate a cardinal direction four times in the clockwise
66 -- (with respect to x) direction, you should wind up with the same
68 prop_four_cwx_is_identity :: Cardinal -> Bool
69 prop_four_cwx_is_identity c =
70 (cwx . cwx . cwx . cwx) c == c
72 -- | If you rotate a cardinal direction four times in the
73 -- counter-clockwise (with respect to x) direction, you should wind up
74 -- with the same direction.
75 prop_four_ccwx_is_identity :: Cardinal -> Bool
76 prop_four_ccwx_is_identity c =
77 (ccwx . ccwx . ccwx . ccwx) c == c
79 -- | If you rotate a cardinal direction four times in the clockwise
80 -- (with respect to y) direction, you should wind up with the same
82 prop_four_cwy_is_identity :: Cardinal -> Bool
83 prop_four_cwy_is_identity c =
84 (cwy . cwy . cwy . cwy) c == c
86 -- | If you rotate a cardinal direction four times in the counter-clockwise
87 -- (with respect to y) direction, you should wind up with the same
89 prop_four_ccwy_is_identity :: Cardinal -> Bool
90 prop_four_ccwy_is_identity c =
91 (ccwy . ccwy . ccwy . ccwy) c == c
93 -- | If you rotate a cardinal direction four times in the clockwise
94 -- (with respect to z) direction, you should wind up with the same
96 prop_four_cwz_is_identity :: Cardinal -> Bool
97 prop_four_cwz_is_identity c =
98 (cwz . cwz . cwz . cwz) c == c
100 -- | If you rotate a cardinal direction four times in the
101 -- counter-clockwise (with respect to z) direction, you should wind up
102 -- with the same direction.
103 prop_four_ccwz_is_identity :: Cardinal -> Bool
104 prop_four_ccwz_is_identity c =
105 (ccwz . ccwz . ccwz . ccwz) c == c