diff options
author | William Carroll <wpcarro@gmail.com> | 2020-08-12T10·24+0100 |
---|---|---|
committer | William Carroll <wpcarro@gmail.com> | 2020-08-12T10·27+0100 |
commit | f11b91c985f95b585820200d0bca5b043fb9f887 (patch) | |
tree | 406ae4e4897eed1d4740d1be702f3d3181617638 /scratch | |
parent | f3ddd89302c9f32d038608882cbe7aa37d9b6577 (diff) |
Adds property tests to generically test keyboard transformations
Tests: - HorizontalFlip - VerticalFlip - Shift n
Diffstat (limited to 'scratch')
-rw-r--r-- | scratch/brilliant/Spec.hs | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/scratch/brilliant/Spec.hs b/scratch/brilliant/Spec.hs index d4b3c9b1961c..78ae8cb50cba 100644 --- a/scratch/brilliant/Spec.hs +++ b/scratch/brilliant/Spec.hs @@ -2,6 +2,7 @@ module Spec where -------------------------------------------------------------------------------- import Test.Hspec +import Test.QuickCheck import Keyboard (Keyboard(..)) import Transforms (Transform(..)) @@ -38,7 +39,30 @@ main = hspec $ do Transforms.fromString "HVS10potato" == Nothing describe "App.transform" $ do - it "flips a keyboard horizontally" $ do + it "flips any keyboard horizontally" $ do + property $ \first second third fourth -> + App.transform (Keyboard [first, second, third, fourth]) HorizontalFlip == do + Keyboard [ reverse first + , reverse second + , reverse third + , reverse fourth + ] + + it "flips any keyboard vertically" $ do + property $ \first second third fourth -> + App.transform (Keyboard [first, second, third, fourth]) VerticalFlip == do + Keyboard $ reverse [first, second, third, fourth] + + it "shifts any keyboard" $ do + property $ \first second third fourth n -> + App.transform (Keyboard [first, second, third, fourth]) (Shift n) == do + Keyboard $ [ Utils.rotate n first + , Utils.rotate n second + , Utils.rotate n third + , Utils.rotate n fourth + ] + + it "flips a QWERTY keyboard horizontally" $ do App.transform Keyboard.qwerty HorizontalFlip == do Keyboard [ ['0','9','8','7','6','5','4','3','2','1'] , ['P','O','I','U','Y','T','R','E','W','Q'] |