@@ -5,6 +5,7 @@ import Verify.Graphics.Vty.DisplayRegion
5import Verify.Graphics.Vty.Picture
5import Verify.Graphics.Vty.Picture
6import Verify.Graphics.Vty.Image
6import Verify.Graphics.Vty.Image
7import Verify.Graphics.Vty.Span
7import Verify.Graphics.Vty.Span
8+import Verify.Graphics.Vty.Terminal
8import Graphics.Vty.Terminal
9import Graphics.Vty.Terminal
9import Graphics.Vty.Terminal.Mock
10import Graphics.Vty.Terminal.Mock
@@ -18,14 +19,6 @@ import qualified Data.String.UTF8 as UTF8
19import System.IO
20import System.IO
21−compare_bytes out_bytes expected_bytes =
22− if out_bytes /= expected_bytes
23− then return $ failed { reason = "bytes\n" ++ show out_bytes
24− ++ "\nare not the expected bytes\n"
25− ++ show expected_bytes
27− else return succeeded
29unit_image_unit_bounds :: UnitImage -> Property
22unit_image_unit_bounds :: UnitImage -> Property
30unit_image_unit_bounds (UnitImage _ i) = liftIOResult $ do
23unit_image_unit_bounds (UnitImage _ i) = liftIOResult $ do
31 (_,t) <- mock_terminal (DisplayRegion 1 1)
24 (_,t) <- mock_terminal (DisplayRegion 1 1)
@@ -50,14 +43,12 @@ single_T_row (MockWindow w h) = liftIOResult $ do
50 let i = horiz_cat $ replicate (fromEnum w) (char def_attr 'T')
43 let i = horiz_cat $ replicate (fromEnum w) (char def_attr 'T')
51 pic = (pic_for_image i) { pic_background = Background 'B' def_attr }
44 pic = (pic_for_image i) { pic_background = Background 'B' def_attr }
52 output_picture dc pic
45 output_picture dc pic
53− out_bytes <- readIORef mock_data >>= return . UTF8.toRep
54− -- The UTF8 string that represents the output bytes a single line containing the T string:
46+ -- The mock output string that represents the output bytes a single line containing the T
47+ -- string: Followed by h - 1 lines of a change to the background attribute and then the
48+ -- background character
55 let expected = "HD" ++ "MA" ++ replicate (fromEnum w) 'T'
49 let expected = "HD" ++ "MA" ++ replicate (fromEnum w) 'T'
56− -- Followed by h - 1 lines of a change to the background attribute and then the background
58 ++ concat (replicate (fromEnum h - 1) $ "MA" ++ replicate (fromEnum w) 'B')
50 ++ concat (replicate (fromEnum h - 1) $ "MA" ++ replicate (fromEnum w) 'B')
59− expected_bytes :: BS.ByteString = UTF8.toRep $ UTF8.fromString expected
51+ compare_mock_output mock_data expected
60− compare_bytes out_bytes expected_bytes
62many_T_rows :: MockWindow -> Property
53many_T_rows :: MockWindow -> Property
63many_T_rows (MockWindow w h) = liftIOResult $ do
54many_T_rows (MockWindow w h) = liftIOResult $ do
@@ -67,12 +58,10 @@ many_T_rows (MockWindow w h) = liftIOResult $ do
67 let i = vert_cat $ replicate (fromEnum h) $ horiz_cat $ replicate (fromEnum w) (char def_attr 'T')
58 let i = vert_cat $ replicate (fromEnum h) $ horiz_cat $ replicate (fromEnum w) (char def_attr 'T')
68 pic = (pic_for_image i) { pic_background = Background 'B' def_attr }
59 pic = (pic_for_image i) { pic_background = Background 'B' def_attr }
69 output_picture dc pic
60 output_picture dc pic
70− out_bytes <- readIORef mock_data >>= return . UTF8.toRep
71 -- The UTF8 string that represents the output bytes is h repeats of a move, 'M', followed by an
61 -- The UTF8 string that represents the output bytes is h repeats of a move, 'M', followed by an
72 -- attribute change. 'A', followed by w 'T's
62 -- attribute change. 'A', followed by w 'T's
73 let expected = "HD" ++ concat (replicate (fromEnum h) $ "MA" ++ replicate (fromEnum w) 'T')
63 let expected = "HD" ++ concat (replicate (fromEnum h) $ "MA" ++ replicate (fromEnum w) 'T')
74− expected_bytes :: BS.ByteString = UTF8.toRep $ UTF8.fromString expected
64+ compare_mock_output mock_data expected
75− compare_bytes out_bytes expected_bytes
77many_T_rows_cropped_width :: MockWindow -> Property
66many_T_rows_cropped_width :: MockWindow -> Property
78many_T_rows_cropped_width (MockWindow w h) = liftIOResult $ do
67many_T_rows_cropped_width (MockWindow w h) = liftIOResult $ do
@@ -82,12 +71,10 @@ many_T_rows_cropped_width (MockWindow w h) = liftIOResult $ do
82 let i = vert_cat $ replicate (fromEnum h) $ horiz_cat $ replicate (fromEnum w * 2) (char def_attr 'T')
71 let i = vert_cat $ replicate (fromEnum h) $ horiz_cat $ replicate (fromEnum w * 2) (char def_attr 'T')
83 pic = (pic_for_image i) { pic_background = Background 'B' def_attr }
72 pic = (pic_for_image i) { pic_background = Background 'B' def_attr }
84 output_picture dc pic
73 output_picture dc pic
85− out_bytes <- readIORef mock_data >>= return . UTF8.toRep
86 -- The UTF8 string that represents the output bytes is h repeats of a move, 'M', followed by an
74 -- The UTF8 string that represents the output bytes is h repeats of a move, 'M', followed by an
87 -- attribute change. 'A', followed by w 'T's
75 -- attribute change. 'A', followed by w 'T's
88 let expected = "HD" ++ concat (replicate (fromEnum h) $ "MA" ++ replicate (fromEnum w) 'T')
76 let expected = "HD" ++ concat (replicate (fromEnum h) $ "MA" ++ replicate (fromEnum w) 'T')
89− expected_bytes :: BS.ByteString = UTF8.toRep $ UTF8.fromString expected
77+ compare_mock_output mock_data expected
90− compare_bytes out_bytes expected_bytes
92many_T_rows_cropped_height :: MockWindow -> Property
79many_T_rows_cropped_height :: MockWindow -> Property
93many_T_rows_cropped_height (MockWindow w h) = liftIOResult $ do
80many_T_rows_cropped_height (MockWindow w h) = liftIOResult $ do
@@ -97,12 +84,10 @@ many_T_rows_cropped_height (MockWindow w h) = liftIOResult $ do
97 let i = vert_cat $ replicate (fromEnum h * 2) $ horiz_cat $ replicate (fromEnum w) (char def_attr 'T')
84 let i = vert_cat $ replicate (fromEnum h * 2) $ horiz_cat $ replicate (fromEnum w) (char def_attr 'T')
98 pic = (pic_for_image i) { pic_background = Background 'B' def_attr }
85 pic = (pic_for_image i) { pic_background = Background 'B' def_attr }
99 output_picture dc pic
86 output_picture dc pic
100− out_bytes <- readIORef mock_data >>= return . UTF8.toRep
101 -- The UTF8 string that represents the output bytes is h repeats of a move, 'M', followed by an
87 -- The UTF8 string that represents the output bytes is h repeats of a move, 'M', followed by an
102 -- attribute change. 'A', followed by w count 'T's
88 -- attribute change. 'A', followed by w count 'T's
103 let expected = "HD" ++ concat (replicate (fromEnum h) $ "MA" ++ replicate (fromEnum w) 'T')
89 let expected = "HD" ++ concat (replicate (fromEnum h) $ "MA" ++ replicate (fromEnum w) 'T')
104− expected_bytes :: BS.ByteString = UTF8.toRep $ UTF8.fromString expected
90+ compare_mock_output mock_data expected
105− compare_bytes out_bytes expected_bytes
107tests :: IO [Test]
92tests :: IO [Test]
108tests = return [ verify "unit_image_unit_bounds" unit_image_unit_bounds
93tests = return [ verify "unit_image_unit_bounds" unit_image_unit_bounds