@@ -5,6 +5,8 @@
55module VerifyUsingMockInput where
66import Verify hiding (classify)
77
8+import Verify.Graphics.Vty.Terminal
9+
810import Graphics.Vty hiding (resize)
911import Graphics.Vty.Input
1012import Graphics.Vty.Input.Data
@@ -46,12 +48,15 @@ assert_events_from_input_block table input_spec expected_events = do
4648 input <- newChan
4749 output <- newChan
4850 forkIO $ write_input_spec_to_chan input input_spec
49− handle (\(e :: BlockedIndefinitelyOnMVar) ->
50− return $ failed { reason = show expected_events ++ " -> " ++ show e }
51− ) $ do
52− inputToEventThread classifier input output
53− out_events <- replicateM (length expected_events) (readChan output)
54− return $ out_events ?== expected_events
51+ inputToEventThread classifier input output
52+ -- H: all events are available in output channel
53+ -- TODO: switch to using explicit control events. Currently the channel is passing around a
54+ -- magic FFFX characters
55+ -- TODO: use STM channel
56+ let collect_events = handle (\(e :: BlockedIndefinitelyOnMVar) -> return [])
57+ ((:) <$> readChan output <*> collect_events)
58+ out_events <- collect_events
59+ return $ out_events ?== expected_events
5560
5661write_input_spec_to_chan :: Chan Char -> InputSpec -> IO ()
5762write_input_spec_to_chan chan [] = writeChan chan '\xFFFD'
@@ -62,15 +67,21 @@ write_input_spec_to_chan chan (Delay t : input_spec')
6267
6368verify_simple_input_block_to_event :: Property
6469verify_simple_input_block_to_event = do
70+ -- Ouch! 16 is as high as this can go without taking far too long. :-\
6571 Positive block_length <- resize 16 $ arbitrary
6672 block_event_pairs <- vectorOf block_length $ elements $ simple_chars
6773 let input = [Bytes $ concatMap fst block_event_pairs]
6874 events = map (\(k,ms) -> EvKey k ms) $ map snd block_event_pairs
6975 morallyDubiousIOProperty $ assert_events_from_input_block simple_chars input events
7076
77+verify_keys_from_caps_table :: String -> Result
78+verify_keys_from_caps_table term_name = succeeded
79+
7180tests :: IO [Test]
7281tests = return
73− [ verify "basic block generated from ansi table to event translation"
74− verify_simple_input_block_to_event
82+ [ verify "basic block generated from single ansi chars to event translation"
83+ verify_simple_input_block_to_event
84+ , verify "keys from caps table are parsed to the same key"
85+ verify_keys_from_caps_table
7586 ]
7687