@@ -1,6 +1,6 @@
1{-# LANGUAGE DisambiguateRecordFields #-}
1{-# LANGUAGE DisambiguateRecordFields #-}
2{-# LANGUAGE NamedFieldPuns #-}
2{-# LANGUAGE NamedFieldPuns #-}
3−module VerifySpanOps where
3+module VerifySimpleSpanGeneration where
5import Verify.Graphics.Vty.DisplayRegion
5import Verify.Graphics.Vty.DisplayRegion
6import Verify.Graphics.Vty.Image
6import Verify.Graphics.Vty.Image
@@ -149,69 +149,6 @@ single_attr_single_span_stack_op_coverage stack =
149 ops = display_ops_for_pic p (region_for_window w)
149 ops = display_ops_for_pic p (region_for_window w)
150 in verify_all_spans_have_width (stack_image stack) ops (stack_width stack)
150 in verify_all_spans_have_width (stack_image stack) ops (stack_width stack)
152−crop_op_display_ops :: (Int -> Image -> Image) ->
153− Int -> Image -> (DisplayOps, Image)
154−crop_op_display_ops crop_op v i =
155− let i_out = crop_op v i
156− p = pic_for_image i_out
157− w = MockWindow (image_width i_out) (image_height i_out)
158− in (display_ops_for_pic p (region_for_window w), i_out)
160−width_crop_output_columns :: (Int -> Image -> Image) ->
161− SingleAttrSingleSpanStack ->
164−width_crop_output_columns crop_op s (NonNegative w) = stack_width s > w ==>
165− let (ops, i_out) = crop_op_display_ops crop_op w (stack_image s)
166− in verify_all_spans_have_width i_out ops w
168−height_crop_output_columns :: (Int -> Image -> Image) ->
169− SingleAttrSingleSpanStack ->
172−height_crop_output_columns crop_op s (NonNegative h) = stack_height s > h ==>
173− let (ops, _) = crop_op_display_ops crop_op h (stack_image s)
174− in display_ops_rows ops == h
176−crop_right_output_columns :: SingleAttrSingleSpanStack -> NonNegative Int -> Property
177−crop_right_output_columns = width_crop_output_columns crop_right
179−crop_left_output_columns :: SingleAttrSingleSpanStack -> NonNegative Int -> Property
180−crop_left_output_columns = width_crop_output_columns crop_left
182−crop_top_output_rows :: SingleAttrSingleSpanStack -> NonNegative Int -> Property
183−crop_top_output_rows = height_crop_output_columns crop_top
185−crop_bottom_output_rows :: SingleAttrSingleSpanStack -> NonNegative Int -> Property
186−crop_bottom_output_rows = height_crop_output_columns crop_bottom
188−-- TODO: known benign failure.
189−crop_right_and_left_rejoined_equivalence :: SingleAttrSingleSpanStack -> Property
190−crop_right_and_left_rejoined_equivalence stack = image_width (stack_image stack) `mod` 2 == 0 ==>
191− let i = stack_image stack
192− -- the right part is made by cropping the image from the left.
193− i_r = crop_left (image_width i `div` 2) i
194− -- the left part is made by cropping the image from the right
195− i_l = crop_right (image_width i `div` 2) i
197− i_ops = display_ops_for_image i
198− i_alt_ops = display_ops_for_image i_alt
199− in if i_ops == i_alt_ops
201− else failed { reason = "ops for alternate image " ++ show i_alt_ops
202− ++ " are not the same as " ++ show i_ops
205−crop_top_and_bottom_rejoined_equivalence :: SingleAttrSingleSpanStack -> Property
206−crop_top_and_bottom_rejoined_equivalence stack = image_height (stack_image stack) `mod` 2 == 0 ==>
207− let i = stack_image stack
208− -- the top part is made by cropping the image from the bottom.
209− i_t = crop_bottom (image_height i `div` 2) i
210− -- the bottom part is made by cropping the image from the top.
211− i_b = crop_top (image_height i `div` 2) i
213− in display_ops_for_image i == display_ops_for_image i_alt
215image_coverage_matches_bounds :: Image -> Result
152image_coverage_matches_bounds :: Image -> Result
216image_coverage_matches_bounds i =
153image_coverage_matches_bounds i =
217 let p = pic_for_image i
154 let p = pic_for_image i
@@ -229,9 +166,6 @@ tests = return
229 , verify "horiz span image is not cropped when window size == size of image [height]" horiz_span_image_and_equal_window_1
166 , verify "horiz span image is not cropped when window size == size of image [height]" horiz_span_image_and_equal_window_1
230 , verify "horiz span image is not cropped when window size < size of image [width]" horiz_span_image_and_lesser_window_0
167 , verify "horiz span image is not cropped when window size < size of image [width]" horiz_span_image_and_lesser_window_0
231 , verify "horiz span image is not cropped when window size > size of image [width]" horiz_span_image_and_greater_window_0
168 , verify "horiz span image is not cropped when window size > size of image [width]" horiz_span_image_and_greater_window_0
232− , verify "arbitrary image is padded or cropped" arb_image_is_cropped
233− , verify "The span ops actually define content for all the rows in the output region" span_ops_actually_fill_rows
234− , verify "The span ops actually define content for all the columns in the output region" span_ops_actually_fill_columns
235 , verify "first span op is always to set the text attribute" first_span_op_sets_attr
169 , verify "first span op is always to set the text attribute" first_span_op_sets_attr
236 , verify "a stack of single attr text spans should define content for all the columns [output region == size of stack]"
170 , verify "a stack of single attr text spans should define content for all the columns [output region == size of stack]"
237 single_attr_single_span_stack_op_coverage
171 single_attr_single_span_stack_op_coverage
@@ -247,19 +181,6 @@ tests = return
247 single_attr_single_span_stack_cropped_4
181 single_attr_single_span_stack_cropped_4
248 , verify "single attr text span <-> single attr text span display cropped. [height]"
182 , verify "single attr text span <-> single attr text span display cropped. [height]"
249 single_attr_single_span_stack_cropped_5
183 single_attr_single_span_stack_cropped_5
250− , verify "cropping from the bottom produces display operations covering the expected rows"
251− crop_bottom_output_rows
252− , verify "cropping from the top produces display operations covering the expected rows"
253− crop_top_output_rows
254− , verify "cropping from the left produces display operations covering the expected columns"
255− crop_left_output_columns
256− , verify "cropping from the right produces display operations covering the expected columns"
257− crop_right_output_columns
258− -- TODO: known benign failure.
259− -- , verify "the output of a stack is the same as that stack cropped left & right and joined together"
260− -- crop_right_and_left_rejoined_equivalence
261− , verify "the output of a stack is the same as that stack cropped top & bottom and joined together"
262− crop_top_and_bottom_rejoined_equivalence
263 , verify "an arbitrary image when rendered to a window of the same size will cover the entire window"
184 , verify "an arbitrary image when rendered to a window of the same size will cover the entire window"
264 image_coverage_matches_bounds
185 image_coverage_matches_bounds