on master help sign in
add a bit more strictness to the resize generator
16c7730Corey O'Connor
README.md+9
@@ -67,3 +67,12 @@ rm -rf dist ; cabal configure --enable-tests --enable-library-coverage \
67 --disable-library-profiling \
67 --disable-library-profiling \
68 --disable-executable-profiling
68 --disable-executable-profiling
69~~~
69~~~
70+
71+## Profiling
72+
73+
74+~~~
75+rm -rf dist ; cabal configure --enable-tests --disable-library-coverage \
76+ --enable-library-profiling \
77+ --enable-executable-profiling
78+~~~
test/Verify/Graphics/Vty/Image.hs+19−6
@@ -69,18 +69,23 @@ newtype ImageResize = ImageResize (Image -> (Image, (Int, Int)))
69
69
70instance Arbitrary ImageResize where
70instance Arbitrary ImageResize where
71 arbitrary = oneof
71 arbitrary = oneof
72+ [ return $! ImageResize $! \i -> (i, (image_width i, image_height i))
73+ , return $! ImageResize $! \i -> (i, (image_width i, image_height i))
74+ , return $! ImageResize $! \i -> (i, (image_width i, image_height i))
75+ , return $! ImageResize $! \i -> (i, (image_width i, image_height i))
76+ , return $! ImageResize $! \i -> (i, (image_width i, image_height i))
72− [ return $ ImageResize $ \i -> (i, (image_width i, image_height i))
77+ , return $! ImageResize $! \i -> (i, (image_width i, image_height i))
73 , do
78 , do
74 ImageResize f <- arbitrary
79 ImageResize f <- arbitrary
75 WidthResize g <- arbitrary
80 WidthResize g <- arbitrary
76− return $ ImageResize $ \i ->
81+ return $! ImageResize $! \i ->
77 let (i_0, (_, out_height)) = f i
82 let (i_0, (_, out_height)) = f i
78 g_i = g i_0
83 g_i = g i_0
79 in (fst g_i, (snd g_i, out_height))
84 in (fst g_i, (snd g_i, out_height))
80 , do
85 , do
81 ImageResize f <- arbitrary
86 ImageResize f <- arbitrary
82 HeightResize g <- arbitrary
87 HeightResize g <- arbitrary
83− return $ ImageResize $ \i ->
88+ return $! ImageResize $! \i ->
84 let (i_0, (out_width, _)) = f i
89 let (i_0, (out_width, _)) = f i
85 g_i = g i_0
90 g_i = g i_0
86 in (fst g_i, (out_width, snd g_i))
91 in (fst g_i, (out_width, snd g_i))
@@ -134,18 +139,26 @@ instance Arbitrary Image where
134 [ do
139 [ do
135 SingleAttrSingleSpanStack {stack_image} <- arbitrary
140 SingleAttrSingleSpanStack {stack_image} <- arbitrary
136 ImageResize f <- arbitrary
141 ImageResize f <- arbitrary
142+ return $! fst $! f stack_image
143+ , do
144+ SingleAttrSingleSpanStack {stack_image} <- arbitrary
145+ ImageResize f <- arbitrary
146+ return $! fst $! f stack_image
147+ , do
148+ SingleAttrSingleSpanStack {stack_image} <- arbitrary
149+ ImageResize f <- arbitrary
137− return $ fst $ f stack_image
150+ return $! fst $! f stack_image
138 , do
151 , do
139 i_0 <- arbitrary
152 i_0 <- arbitrary
140 i_1 <- arbitrary
153 i_1 <- arbitrary
141 let i = i_0 <|> i_1
154 let i = i_0 <|> i_1
142 ImageResize f <- arbitrary
155 ImageResize f <- arbitrary
143− return $ fst $ f i
156+ return $! fst $! f i
144 , do
157 , do
145 i_0 <- arbitrary
158 i_0 <- arbitrary
146 i_1 <- arbitrary
159 i_1 <- arbitrary
147 let i = i_0 <-> i_1
160 let i = i_0 <-> i_1
148 ImageResize f <- arbitrary
161 ImageResize f <- arbitrary
149− return $ fst $ f i
162+ return $! fst $! f i
150 ]
163 ]
151
164
test/VerifySpanOps.hs+16−7
@@ -149,6 +149,13 @@ single_attr_single_span_stack_op_coverage stack =
149 spans = spans_for_pic p (region_for_window w)
149 spans = spans_for_pic p (region_for_window w)
150 in verify_all_spans_have_width (stack_image stack) spans (stack_width stack)
150 in verify_all_spans_have_width (stack_image stack) spans (stack_width stack)
151
151
152+image_coverage_matches_bounds :: Image -> Result
153+image_coverage_matches_bounds i =
154+ let p = pic_for_image i
155+ r = DisplayRegion (image_width i) (image_height i)
156+ spans = spans_for_pic p r
157+ in verify_all_spans_have_width i spans (image_width i)
158+
152tests :: IO [Test]
159tests :: IO [Test]
153tests = return
160tests = return
154 [ verify "unit image is cropped when window size == (0,0) [0]" unit_image_and_zero_window_0
161 [ verify "unit image is cropped when window size == (0,0) [0]" unit_image_and_zero_window_0
@@ -164,18 +171,20 @@ tests = return
164 , verify "The span ops actually define content for all the columns in the output region" span_ops_actually_fill_columns
171 , verify "The span ops actually define content for all the columns in the output region" span_ops_actually_fill_columns
165 , verify "first span op is always to set the text attribute" first_span_op_sets_attr
172 , verify "first span op is always to set the text attribute" first_span_op_sets_attr
166 , verify "a stack of single attr text spans should define content for all the columns [output region == size of stack]"
173 , verify "a stack of single attr text spans should define content for all the columns [output region == size of stack]"
167− single_attr_single_span_stack_op_coverage
174+ single_attr_single_span_stack_op_coverage
168 , verify "a single attr text span is cropped when window size < size of stack image [width]"
175 , verify "a single attr text span is cropped when window size < size of stack image [width]"
169− single_attr_single_span_stack_cropped_0
176+ single_attr_single_span_stack_cropped_0
170 , verify "a single attr text span is cropped when window size < size of stack image [height]"
177 , verify "a single attr text span is cropped when window size < size of stack image [height]"
171− single_attr_single_span_stack_cropped_1
178+ single_attr_single_span_stack_cropped_1
172 , verify "single attr text span <|> single attr text span cropped. [width]"
179 , verify "single attr text span <|> single attr text span cropped. [width]"
173− single_attr_single_span_stack_cropped_2
180+ single_attr_single_span_stack_cropped_2
174 , verify "single attr text span <|> single attr text span cropped. [height]"
181 , verify "single attr text span <|> single attr text span cropped. [height]"
175− single_attr_single_span_stack_cropped_3
182+ single_attr_single_span_stack_cropped_3
176 , verify "single attr text span <-> single attr text span cropped. [width]"
183 , verify "single attr text span <-> single attr text span cropped. [width]"
177− single_attr_single_span_stack_cropped_4
184+ single_attr_single_span_stack_cropped_4
178 , verify "single attr text span <-> single attr text span cropped. [height]"
185 , verify "single attr text span <-> single attr text span cropped. [height]"
179− single_attr_single_span_stack_cropped_5
186+ single_attr_single_span_stack_cropped_5
187+ , verify "an arbitrary image when rendered to a window of the same size will cover the entire window"
188+ image_coverage_matches_bounds
180 ]
189 ]
181
190
test/VerifyTerminfoBased.hs+2−2
@@ -27,8 +27,8 @@ tests = concat <$> forM terminals_of_interest (\term_name -> do
27 ]
27 ]
28 )
28 )
29
29
30−smoke_test_term :: String -> SingleAttrSingleSpanStack -> Property
30+smoke_test_term :: String -> Image -> Property
31−smoke_test_term term_name (SingleAttrSingleSpanStack i _ _ _) = liftIOResult $ do
31+smoke_test_term term_name i = liftIOResult $ do
32 null_out <- openFile "/dev/null" WriteMode
32 null_out <- openFile "/dev/null" WriteMode
33 t <- TerminfoBased.reserve_terminal term_name null_out
33 t <- TerminfoBased.reserve_terminal term_name null_out
34 putStrLn $ "context color count: " ++ show (context_color_count t)
34 putStrLn $ "context color count: " ++ show (context_color_count t)