about summary refs log tree commit diff
path: root/scratch/brilliant/Spec.hs
diff options
context:
space:
mode:
authorWilliam Carroll <wpcarro@gmail.com>2020-08-05T22·20+0100
committerWilliam Carroll <wpcarro@gmail.com>2020-08-05T22·21+0100
commit244503bba91c9a99c9ab5a6a74b74d5c9bd9667e (patch)
treee26248c17d4374ab69647e461613b5bb15a1513c /scratch/brilliant/Spec.hs
parent61a2fb108dcdcc599ad9fe9de7b02d1181aec2d1 (diff)
Support App.transform
Apply the transform to a Keyboard. Onwards to the final demonstration!
Diffstat (limited to 'scratch/brilliant/Spec.hs')
-rw-r--r--scratch/brilliant/Spec.hs36
1 files changed, 36 insertions, 0 deletions
diff --git a/scratch/brilliant/Spec.hs b/scratch/brilliant/Spec.hs
index f49a3d3d96a4..c55da72d0c37 100644
--- a/scratch/brilliant/Spec.hs
+++ b/scratch/brilliant/Spec.hs
@@ -4,10 +4,13 @@ module Spec where
 import Test.Hspec
 import Test.QuickCheck
 import Control.Exception (evaluate)
+import Keyboard (Keyboard(..))
 import Transforms (Transform(..))
 
+import qualified App
 import qualified Keyboard
 import qualified Transforms
+import qualified Utils
 --------------------------------------------------------------------------------
 
 main :: IO ()
@@ -35,3 +38,36 @@ main = hspec $ do
 
     it "return Nothing when the input is valid except for the end" $ do
       Transforms.fromString "HVS10potato" == Nothing
+
+  describe "App.transform" $ do
+    it "flips a keyboard horizontally" $ do
+      App.transform HorizontalFlip Keyboard.qwerty == do
+        Keyboard [ reverse ['1','2','3','4','5','6','7','8','9','0']
+                 , reverse ['Q','W','E','R','T','Y','U','I','O','P']
+                 , reverse ['A','S','D','F','G','H','J','K','L',';']
+                 , reverse ['Z','X','C','V','B','N','M',',','.','/']
+                 ]
+
+    it "flips a keyboard vertically" $ do
+      App.transform VerticalFlip Keyboard.qwerty == do
+        Keyboard $ reverse [ ['1','2','3','4','5','6','7','8','9','0']
+                           , ['Q','W','E','R','T','Y','U','I','O','P']
+                           , ['A','S','D','F','G','H','J','K','L',';']
+                           , ['Z','X','C','V','B','N','M',',','.','/']
+                           ]
+
+    it "shifts a keyboard N times" $ do
+      App.transform (Shift 2) Keyboard.qwerty == do
+        Keyboard $ [ Utils.rotate 2 ['1','2','3','4','5','6','7','8','9','0']
+                   , Utils.rotate 2 ['Q','W','E','R','T','Y','U','I','O','P']
+                   , Utils.rotate 2 ['A','S','D','F','G','H','J','K','L',';']
+                   , Utils.rotate 2 ['Z','X','C','V','B','N','M',',','.','/']
+                   ]
+
+    it "shifts negative amounts" $ do
+      App.transform (Shift (-3)) Keyboard.qwerty == do
+        Keyboard $ [ Utils.rotate (-3) ['1','2','3','4','5','6','7','8','9','0']
+                   , Utils.rotate (-3) ['Q','W','E','R','T','Y','U','I','O','P']
+                   , Utils.rotate (-3) ['A','S','D','F','G','H','J','K','L',';']
+                   , Utils.rotate (-3) ['Z','X','C','V','B','N','M',',','.','/']
+                   ]