on e08a59e help sign in
vty/test/VerifyUsingMockInput.hs
49 lines 1.6 kB history raw
1{- We setup the environment to envoke certain terminals of interest.
2 - This assumes appropriate definitions exist in the current environment for the terminals of
3 - interest.
4 -}
5module VerifyUsingMockInput where
6import Verify
8import Graphics.Vty
9import Graphics.Vty.Input.Data
11import Control.Concurrent
12import Control.Monad
14import System.Posix.Env
15import System.IO
17data InputEvent
18 = Bytes String -- | input sequence encoded as a string. Regardless, the input is read a byte at a time.
19 | Delay Int -- | millisecond delay
21type InputSpec = [InputEvent]
23type ExpectedSpec = [Event]
25exec_input_spec :: InputSpec -> Handle -> IO ()
26exec_input_spec input out_handle = forM_ input f
27 where
28 f (Bytes str) = hPutStr out_handle str >> hFlush out_handle
29 f (Delay t) = threadDelay (t*1000)
31assert_events_from_IO_reads :: InputSpec -> ExpectedSpec -> IO Result
32assert_events_from_IO_reads input events = undefined
34assert_events_from_input_block :: InputSpec -> ExpectedSpec -> Result
35assert_events_from_input_block input events = undefined
37verify_ansi_table_input_block_to_event :: Gen Result
38verify_ansi_table_input_block_to_event = do
39 Positive block_length <- arbitrary
40 block_event_pairs <- vectorOf block_length $ elements $ concat ansi_classify_table
41 let input = [Bytes $ concatMap fst block_event_pairs]
42 events = map (\(k,ms) -> EvKey k ms) $ map snd block_event_pairs
43 return $ assert_events_from_input_block input events
45tests :: IO [Test]
46tests = return
47 [ verify "basic input block to event translation" verify_ansi_table_input_block_to_event
48 ]