@@ -1,3 +1,5 @@
1+{-# LANGUAGE MultiParamTypeClasses #-}
2+{-# LANGUAGE FlexibleInstances #-}
13{- We setup the environment to envoke certain terminals of interest.
24 - This assumes appropriate definitions exist in the current environment for the terminals of
35 - interest.
@@ -22,6 +24,7 @@ import System.IO
2224import Test.Framework.Providers.SmallCheck
2325import Test.Framework
2426import Test.SmallCheck
27+import Test.SmallCheck.Series
2528
2629-- processing a block of 16 chars is the largest I can do without taking too long to run the test.
2730max_bytes_size = 16
@@ -80,21 +83,22 @@ tests = do
8083 , verify "keys from caps table are parsed to the same key"
8184 verify_keys_from_caps_table
8285 ]
86+-}
87+
88+data SimpleEvent = SimpleEvent (String, (Key, [Modifier]))
89+ deriving (Show)
8390
91+instance Monad m => Serial m SimpleEvent where
92+ series = generate (\n -> map SimpleEvent $ take n simple_chars)
8493
85−verify_simple_input_block_to_event :: Int -> IO (Property IO)
86−verify_simple_input_block_to_event = do
87− -- Ouch! 16 is as high as this can go without taking far too long. :-\
88− Positive block_length <- resize 16 $ arbitrary
89− block_event_pairs <- vectorOf block_length $ elements $ simple_chars
90− let input = [Bytes $ concatMap fst block_event_pairs]
91− events = map (\(k,ms) -> EvKey k ms) $ map snd block_event_pairs
92− morallyDubiousIOProperty $ assert_events_from_input_block simple_chars input events
94+verify_simple_input_block_to_event :: Property IO
95+verify_simple_input_block_to_event = forAll $ \input_spec -> do
96+ let input = Bytes $ concat [s | SimpleEvent (s,_) <- input_spec]
97+ events = [e | SimpleEvent (_,(k,ms)) <- input_spec, let e = EvKey k ms]
98+ monadic $ assert_events_from_input_block simple_chars [input] events
9399
94100main = defaultMain
95101 [ testProperty "basic block generated from a single ansi chars to event translation"
96102 verify_simple_input_block_to_event
97103 ]
98−-}
99−main = defaultMain []
100104