@@ -5,6 +5,8 @@
5module VerifyUsingMockInput where
5module VerifyUsingMockInput where
6import Verify hiding (classify)
6import Verify hiding (classify)
8+import Verify.Graphics.Vty.Terminal
8import Graphics.Vty hiding (resize)
10import Graphics.Vty hiding (resize)
9import Graphics.Vty.Input
11import Graphics.Vty.Input
10import Graphics.Vty.Input.Data
12import Graphics.Vty.Input.Data
@@ -46,12 +48,15 @@ assert_events_from_input_block table input_spec expected_events = do
46 input <- newChan
48 input <- newChan
47 output <- newChan
49 output <- newChan
48 forkIO $ write_input_spec_to_chan input input_spec
50 forkIO $ write_input_spec_to_chan input input_spec
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
49− handle (\(e :: BlockedIndefinitelyOnMVar) ->
56+ let collect_events = handle (\(e :: BlockedIndefinitelyOnMVar) -> return [])
50− return $ failed { reason = show expected_events ++ " -> " ++ show e }
57+ ((:) <$> readChan output <*> collect_events)
51− ) $ do
58+ out_events <- collect_events
52− inputToEventThread classifier input output
53− out_events <- replicateM (length expected_events) (readChan output)
54− return $ out_events ?== expected_events
59+ return $ out_events ?== expected_events
56write_input_spec_to_chan :: Chan Char -> InputSpec -> IO ()
61write_input_spec_to_chan :: Chan Char -> InputSpec -> IO ()
57write_input_spec_to_chan chan [] = writeChan chan '\xFFFD'
62write_input_spec_to_chan chan [] = writeChan chan '\xFFFD'
@@ -62,15 +67,21 @@ write_input_spec_to_chan chan (Delay t : input_spec')
63verify_simple_input_block_to_event :: Property
68verify_simple_input_block_to_event :: Property
64verify_simple_input_block_to_event = do
69verify_simple_input_block_to_event = do
70+ -- Ouch! 16 is as high as this can go without taking far too long. :-\
65 Positive block_length <- resize 16 $ arbitrary
71 Positive block_length <- resize 16 $ arbitrary
66 block_event_pairs <- vectorOf block_length $ elements $ simple_chars
72 block_event_pairs <- vectorOf block_length $ elements $ simple_chars
67 let input = [Bytes $ concatMap fst block_event_pairs]
73 let input = [Bytes $ concatMap fst block_event_pairs]
68 events = map (\(k,ms) -> EvKey k ms) $ map snd block_event_pairs
74 events = map (\(k,ms) -> EvKey k ms) $ map snd block_event_pairs
69 morallyDubiousIOProperty $ assert_events_from_input_block simple_chars input events
75 morallyDubiousIOProperty $ assert_events_from_input_block simple_chars input events
77+verify_keys_from_caps_table :: String -> Result
78+verify_keys_from_caps_table term_name = succeeded
71tests :: IO [Test]
80tests :: IO [Test]
72tests = return
81tests = return
73− [ verify "basic block generated from ansi table to event translation"
82+ [ verify "basic block generated from single ansi chars to event translation"
74− verify_simple_input_block_to_event
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