on 5.3 help sign in
vty/test/VerifyConfig.hs
44 lines 1.3 kB history raw
1{-# LANGUAGE QuasiQuotes #-}
2module Main where
4import Graphics.Vty.Config
5import Graphics.Vty.Input.Events
7import Data.Default
8import Data.String.QQ
10import Test.Framework
11import Test.Framework.Providers.HUnit
12import Test.HUnit hiding (Test)
14exampleConfig :: String
15exampleConfig = [s|
16-- comments should be ignored.
17map _ "\ESC[B" KUp []
18askfjla dfasjdflk jasdlkfj asdfj -- lines failing parse should be ignored
19map _ "\ESC[1;3B" KDown [MAlt]
20map "xterm" "\ESC[1;3B" KDown [MAlt]
21map "xterm-256-color" "\ESC[1;3B" KDown [MAlt]
22debugLog "/tmp/vty-debug.txt"
23|]
25exampleConfigConfig :: Config
26exampleConfigConfig = def
27 { debugLog = Just "/tmp/vty-debug.txt"
28 , inputMap = [ (Nothing, "\ESC[B", EvKey KUp [])
29 , (Nothing, "\ESC[1;3B", EvKey KDown [MAlt])
30 , (Just "xterm", "\ESC[1;3B", EvKey KDown [MAlt])
31 , (Just "xterm-256-color", "\ESC[1;3B", EvKey KDown [MAlt])
32 ]
33 }
35exampleConfigParses :: IO ()
36exampleConfigParses = assertEqual "example config parses as expected"
37 exampleConfigConfig
38 (runParseConfig "exampleConfig" exampleConfig)
40main :: IO ()
41main = defaultMain
42 [ testCase "example config parses" $ exampleConfigParses
43 ]