@@ -48,7 +48,7 @@ tests = do
48 liftIO $ putStrLn case_name
48 liftIO $ putStrLn case_name
49 return $ case Terminfo.getCapability ti (Terminfo.tiGetStr cap_name) of
49 return $ case Terminfo.getCapability ti (Terminfo.tiGetStr cap_name) of
50 Just cap_def -> [verify (case_name ++ " -> " ++ show cap_def)
50 Just cap_def -> [verify (case_name ++ " -> " ++ show cap_def)
51− (verify_parse_cap cap_def $ const (return succeeded))]
51+ (verify_parse_cap cap_def $ const succeeded)]
52 Nothing -> []
52 Nothing -> []
@@ -59,46 +59,36 @@ tests = do
59 , verify "parse cap string with %pN op" push_param_caps
59 , verify "parse cap string with %pN op" push_param_caps
60 ] ++ parse_tests
60 ] ++ parse_tests
62−verify_parse_cap cap_string on_parse = liftIOResult $ do
62+verify_parse_cap cap_string on_parse =
63− parse_result <- parse_cap_expression cap_string
63+ case parse_cap_expression cap_string of
65− Left error -> return $ failed { reason = "parse error " ++ show error }
64+ Left error -> failed { reason = "parse error " ++ show error }
66− Right e -> on_parse e
65+ Right e -> on_parse e
68non_paramaterized_caps (NonParamCapString cap) = do
67non_paramaterized_caps (NonParamCapString cap) = do
69 verify_parse_cap cap $ \e ->
68 verify_parse_cap cap $ \e ->
70− let expected_count :: Word8 = toEnum $ length cap
71− expected_bytes = map (toEnum . fromEnum) cap
69+ let expected_bytes = map (toEnum . fromEnum) cap
72− out_bytes = bytes_for_range e 0 expected_count
70+ out_bytes = bytes_for_range e 0 (length cap)
73− in return $ verify_bytes_equal out_bytes expected_bytes
71+ in verify_bytes_equal out_bytes expected_bytes
75literal_percent_caps (LiteralPercentCap cap_string expected_bytes) = do
73literal_percent_caps (LiteralPercentCap cap_string expected_bytes) = do
76− verify_parse_cap cap_string $ \e ->
74+ verify_parse_cap cap_string $ \e -> verify_bytes_equal (collect_bytes e) expected_bytes
77− let expected_count :: Word8 = toEnum $ length expected_bytes
78− out_bytes = collect_bytes e
79− in return $ verify_bytes_equal out_bytes expected_bytes
81inc_first_two_caps (IncFirstTwoCap cap_string expected_bytes) = do
76inc_first_two_caps (IncFirstTwoCap cap_string expected_bytes) = do
82− verify_parse_cap cap_string $ \e ->
77+ verify_parse_cap cap_string $ \e -> verify_bytes_equal (collect_bytes e) expected_bytes
83− let expected_count :: Word8 = toEnum $ length expected_bytes
84− out_bytes = collect_bytes e
85− in return $ verify_bytes_equal out_bytes expected_bytes
87push_param_caps (PushParamCap cap_string expected_param_count expected_bytes) = do
79push_param_caps (PushParamCap cap_string expected_param_count expected_bytes) = do
88 verify_parse_cap cap_string $ \e ->
80 verify_parse_cap cap_string $ \e ->
89− let expected_count :: Word8 = toEnum $ length expected_bytes
90− out_bytes = collect_bytes e
81+ let out_bytes = collect_bytes e
91 out_param_count = param_count e
82 out_param_count = param_count e
92− in return $ if out_param_count == expected_param_count
83+ in if out_param_count == expected_param_count
93 then verify_bytes_equal out_bytes expected_bytes
84 then verify_bytes_equal out_bytes expected_bytes
94 else failed { reason = "out param count /= expected param count" }
85 else failed { reason = "out param count /= expected param count" }
96dec_print_param_caps (DecPrintCap cap_string expected_param_count expected_bytes) = do
87dec_print_param_caps (DecPrintCap cap_string expected_param_count expected_bytes) = do
97 verify_parse_cap cap_string $ \e ->
88 verify_parse_cap cap_string $ \e ->
98− let expected_count :: Word8 = toEnum $ length expected_bytes
99− out_bytes = collect_bytes e
89+ let out_bytes = collect_bytes e
100 out_param_count = param_count e
90 out_param_count = param_count e
101− in return $ if out_param_count == expected_param_count
91+ in if out_param_count == expected_param_count
102 then verify_bytes_equal out_bytes expected_bytes
92 then verify_bytes_equal out_bytes expected_bytes
103 else failed { reason = "out param count /= expected param count" }
93 else failed { reason = "out param count /= expected param count" }
@@ -106,6 +96,6 @@ print_cap ti cap_name = do
106 putStrLn $ cap_name ++ ": " ++ show (from_capname ti cap_name)
96 putStrLn $ cap_name ++ ": " ++ show (from_capname ti cap_name)
108print_expression ti cap_name = do
98print_expression ti cap_name = do
109− parse_result <- parse_cap_expression $ from_capname ti cap_name
99+ let parse_result = parse_cap_expression $ from_capname ti cap_name
110 putStrLn $ cap_name ++ ": " ++ show parse_result
100 putStrLn $ cap_name ++ ": " ++ show parse_result