@@ -98,7 +98,7 @@ main = do
98 case Terminfo.getCapability ti (Terminfo.tiGetStr cap_name) of
98 case Terminfo.getCapability ti (Terminfo.tiGetStr cap_name) of
99 Just cap_def -> do
99 Just cap_def -> do
100 verify ( "\tparse cap " ++ cap_name ++ " -> " ++ show cap_def )
100 verify ( "\tparse cap " ++ cap_name ++ " -> " ++ show cap_def )
101− ( verify_parse_cap cap_def $ const (liftResult succeeded) )
101+ ( verify_parse_cap cap_def $ const ( return succeeded ) )
102 return ()
102 return ()
103 Nothing -> do
103 Nothing -> do
104 return ()
104 return ()
@@ -110,9 +110,10 @@ main = do
110 return ()
110 return ()
111 return ()
111 return ()
113−verify_parse_cap cap_string on_parse = do
113+verify_parse_cap cap_string on_parse = liftIOResult $ do
114− case parse_cap_expression cap_string of
114+ parse_result <- parse_cap_expression cap_string
115+ case parse_result of
115− Left error -> liftResult $ failed { reason = "parse error " ++ show error }
116+ Left error -> return $ failed { reason = "parse error " ++ show error }
116 Right e -> on_parse e
117 Right e -> on_parse e
118non_paramaterized_caps (NonParamCapString cap) = do
119non_paramaterized_caps (NonParamCapString cap) = do
@@ -120,39 +121,42 @@ non_paramaterized_caps (NonParamCapString cap) = do
120 let expected_count :: Word8 = toEnum $ length cap
121 let expected_count :: Word8 = toEnum $ length cap
121 expected_bytes = map (toEnum . fromEnum) cap
122 expected_bytes = map (toEnum . fromEnum) cap
122 out_bytes = bytes_for_range e 0 expected_count
123 out_bytes = bytes_for_range e 0 expected_count
123− in verify_bytes_equal out_bytes expected_bytes
124+ in return $ verify_bytes_equal out_bytes expected_bytes
125literal_percent_caps (LiteralPercentCap cap_string expected_bytes) = do
126literal_percent_caps (LiteralPercentCap cap_string expected_bytes) = do
126 verify_parse_cap cap_string $ \e ->
127 verify_parse_cap cap_string $ \e ->
127 let expected_count :: Word8 = toEnum $ length expected_bytes
128 let expected_count :: Word8 = toEnum $ length expected_bytes
128 out_bytes = collect_bytes e
129 out_bytes = collect_bytes e
129− in verify_bytes_equal out_bytes expected_bytes
130+ in return $ verify_bytes_equal out_bytes expected_bytes
131inc_first_two_caps (IncFirstTwoCap cap_string expected_bytes) = do
132inc_first_two_caps (IncFirstTwoCap cap_string expected_bytes) = do
132 verify_parse_cap cap_string $ \e ->
133 verify_parse_cap cap_string $ \e ->
133 let expected_count :: Word8 = toEnum $ length expected_bytes
134 let expected_count :: Word8 = toEnum $ length expected_bytes
134 out_bytes = collect_bytes e
135 out_bytes = collect_bytes e
135− in verify_bytes_equal out_bytes expected_bytes
136+ in return $ verify_bytes_equal out_bytes expected_bytes
137push_param_caps (PushParamCap cap_string expected_param_count expected_bytes) = do
138push_param_caps (PushParamCap cap_string expected_param_count expected_bytes) = do
138 verify_parse_cap cap_string $ \e ->
139 verify_parse_cap cap_string $ \e ->
139 let expected_count :: Word8 = toEnum $ length expected_bytes
140 let expected_count :: Word8 = toEnum $ length expected_bytes
140 out_bytes = collect_bytes e
141 out_bytes = collect_bytes e
141 out_param_count = param_count e
142 out_param_count = param_count e
143+ in return $ if out_param_count == expected_param_count
142− in verify_bytes_equal out_bytes expected_bytes
144+ then verify_bytes_equal out_bytes expected_bytes
143− .&. out_param_count == expected_param_count
145+ else failed { reason = "out param count /= expected param count" }
145dec_print_param_caps (DecPrintCap cap_string expected_param_count expected_bytes) = do
147dec_print_param_caps (DecPrintCap cap_string expected_param_count expected_bytes) = do
146 verify_parse_cap cap_string $ \e ->
148 verify_parse_cap cap_string $ \e ->
147 let expected_count :: Word8 = toEnum $ length expected_bytes
149 let expected_count :: Word8 = toEnum $ length expected_bytes
148 out_bytes = collect_bytes e
150 out_bytes = collect_bytes e
149 out_param_count = param_count e
151 out_param_count = param_count e
152+ in return $ if out_param_count == expected_param_count
150− in verify_bytes_equal out_bytes expected_bytes
153+ then verify_bytes_equal out_bytes expected_bytes
151− .&. out_param_count == expected_param_count
154+ else failed { reason = "out param count /= expected param count" }
153print_cap ti cap_name = do
156print_cap ti cap_name = do
154 putStrLn $ cap_name ++ ": " ++ show (from_capname ti cap_name)
157 putStrLn $ cap_name ++ ": " ++ show (from_capname ti cap_name)
156print_expression ti cap_name = do
159print_expression ti cap_name = do
157− putStrLn $ cap_name ++ ": " ++ show (parse_cap_expression $ from_capname ti cap_name)
160+ parse_result <- parse_cap_expression $ from_capname ti cap_name
161+ putStrLn $ cap_name ++ ": " ++ show parse_result