on master help sign in
split the VerifySpanOps test into two. add boilerplate for layers tests
8131ac3Corey O'Connor
test/VerifyCropSpanGeneration.hsnew file+96
@@ -0,0 +1,96 @@
1+{-# LANGUAGE DisambiguateRecordFields #-}
2+{-# LANGUAGE NamedFieldPuns #-}
3+module VerifyCropSpanGeneration where
4+
5+import Verify.Graphics.Vty.DisplayRegion
6+import Verify.Graphics.Vty.Image
7+import Verify.Graphics.Vty.Picture
8+import Verify.Graphics.Vty.Span
9+
10+import Graphics.Vty.Debug
11+import Graphics.Vty.PictureToSpans
12+
13+import Verify
14+
15+import qualified Data.Vector as Vector
16+
17+crop_op_display_ops :: (Int -> Image -> Image) ->
18+ Int -> Image -> (DisplayOps, Image)
19+crop_op_display_ops crop_op v i =
20+ let i_out = crop_op v i
21+ p = pic_for_image i_out
22+ w = MockWindow (image_width i_out) (image_height i_out)
23+ in (display_ops_for_pic p (region_for_window w), i_out)
24+
25+width_crop_output_columns :: (Int -> Image -> Image) ->
26+ SingleAttrSingleSpanStack ->
27+ NonNegative Int ->
28+ Property
29+width_crop_output_columns crop_op s (NonNegative w) = stack_width s > w ==>
30+ let (ops, i_out) = crop_op_display_ops crop_op w (stack_image s)
31+ in verify_all_spans_have_width i_out ops w
32+
33+height_crop_output_columns :: (Int -> Image -> Image) ->
34+ SingleAttrSingleSpanStack ->
35+ NonNegative Int ->
36+ Property
37+height_crop_output_columns crop_op s (NonNegative h) = stack_height s > h ==>
38+ let (ops, _) = crop_op_display_ops crop_op h (stack_image s)
39+ in display_ops_rows ops == h
40+
41+crop_right_output_columns :: SingleAttrSingleSpanStack -> NonNegative Int -> Property
42+crop_right_output_columns = width_crop_output_columns crop_right
43+
44+crop_left_output_columns :: SingleAttrSingleSpanStack -> NonNegative Int -> Property
45+crop_left_output_columns = width_crop_output_columns crop_left
46+
47+crop_top_output_rows :: SingleAttrSingleSpanStack -> NonNegative Int -> Property
48+crop_top_output_rows = height_crop_output_columns crop_top
49+
50+crop_bottom_output_rows :: SingleAttrSingleSpanStack -> NonNegative Int -> Property
51+crop_bottom_output_rows = height_crop_output_columns crop_bottom
52+
53+-- TODO: known benign failure.
54+crop_right_and_left_rejoined_equivalence :: SingleAttrSingleSpanStack -> Property
55+crop_right_and_left_rejoined_equivalence stack = image_width (stack_image stack) `mod` 2 == 0 ==>
56+ let i = stack_image stack
57+ -- the right part is made by cropping the image from the left.
58+ i_r = crop_left (image_width i `div` 2) i
59+ -- the left part is made by cropping the image from the right
60+ i_l = crop_right (image_width i `div` 2) i
61+ i_alt = i_l <|> i_r
62+ i_ops = display_ops_for_image i
63+ i_alt_ops = display_ops_for_image i_alt
64+ in if i_ops == i_alt_ops
65+ then succeeded
66+ else failed { reason = "ops for alternate image " ++ show i_alt_ops
67+ ++ " are not the same as " ++ show i_ops
68+ }
69+
70+crop_top_and_bottom_rejoined_equivalence :: SingleAttrSingleSpanStack -> Property
71+crop_top_and_bottom_rejoined_equivalence stack = image_height (stack_image stack) `mod` 2 == 0 ==>
72+ let i = stack_image stack
73+ -- the top part is made by cropping the image from the bottom.
74+ i_t = crop_bottom (image_height i `div` 2) i
75+ -- the bottom part is made by cropping the image from the top.
76+ i_b = crop_top (image_height i `div` 2) i
77+ i_alt = i_t <-> i_b
78+ in display_ops_for_image i == display_ops_for_image i_alt
79+
80+tests :: IO [Test]
81+tests = return
82+ [ verify "cropping from the bottom produces display operations covering the expected rows"
83+ crop_bottom_output_rows
84+ , verify "cropping from the top produces display operations covering the expected rows"
85+ crop_top_output_rows
86+ , verify "cropping from the left produces display operations covering the expected columns"
87+ crop_left_output_columns
88+ , verify "cropping from the right produces display operations covering the expected columns"
89+ crop_right_output_columns
90+ -- TODO: known benign failure.
91+ -- , verify "the output of a stack is the same as that stack cropped left & right and joined together"
92+ -- crop_right_and_left_rejoined_equivalence
93+ , verify "the output of a stack is the same as that stack cropped top & bottom and joined together"
94+ crop_top_and_bottom_rejoined_equivalence
95+ ]
96+
test/VerifyLayersSpanGeneration.hsnew file+20
@@ -0,0 +1,20 @@
1+{-# LANGUAGE DisambiguateRecordFields #-}
2+{-# LANGUAGE NamedFieldPuns #-}
3+module VerifyLayersSpanGeneration where
4+
5+import Verify.Graphics.Vty.DisplayRegion
6+import Verify.Graphics.Vty.Image
7+import Verify.Graphics.Vty.Picture
8+import Verify.Graphics.Vty.Span
9+
10+import Graphics.Vty.Debug
11+import Graphics.Vty.PictureToSpans
12+
13+import Verify
14+
15+import qualified Data.Vector as Vector
16+
17+tests :: IO [Test]
18+tests = return
19+ [ ]
20+
test/VerifyPictureOps.hsdeleted−8
@@ -1,8 +0,0 @@
1−module VerifyPictureOps where
2−
3−import Graphics.Vty.Picture ( translate )
4−
5−import Verify
6−
7−tests :: IO [Test]
8−tests = return []
test/VerifyPictureToSpan.hsdeleted−10
@@ -1,10 +0,0 @@
1−module VerifyPictureToSpan where
2−
3−import Graphics.Vty.Picture
4−import Graphics.Vty.Span
5−import Graphics.Vty.PictureToSpans
6−
7−import Verify
8−
9−tests :: IO [Test]
10−tests = return []
test/VerifySpanOps.hs → test/VerifySimpleSpanGeneration.hsrenamed+1−80
@@ -1,6 +1,6 @@
1{-# LANGUAGE DisambiguateRecordFields #-}
1{-# LANGUAGE DisambiguateRecordFields #-}
2{-# LANGUAGE NamedFieldPuns #-}
2{-# LANGUAGE NamedFieldPuns #-}
3−module VerifySpanOps where
3+module VerifySimpleSpanGeneration where
4
4
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)
151
151
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)
159−
160−width_crop_output_columns :: (Int -> Image -> Image) ->
161− SingleAttrSingleSpanStack ->
162− NonNegative Int ->
163− Property
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
167−
168−height_crop_output_columns :: (Int -> Image -> Image) ->
169− SingleAttrSingleSpanStack ->
170− NonNegative Int ->
171− Property
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
175−
176−crop_right_output_columns :: SingleAttrSingleSpanStack -> NonNegative Int -> Property
177−crop_right_output_columns = width_crop_output_columns crop_right
178−
179−crop_left_output_columns :: SingleAttrSingleSpanStack -> NonNegative Int -> Property
180−crop_left_output_columns = width_crop_output_columns crop_left
181−
182−crop_top_output_rows :: SingleAttrSingleSpanStack -> NonNegative Int -> Property
183−crop_top_output_rows = height_crop_output_columns crop_top
184−
185−crop_bottom_output_rows :: SingleAttrSingleSpanStack -> NonNegative Int -> Property
186−crop_bottom_output_rows = height_crop_output_columns crop_bottom
187−
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
196− i_alt = i_l <|> i_r
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
200− then succeeded
201− else failed { reason = "ops for alternate image " ++ show i_alt_ops
202− ++ " are not the same as " ++ show i_ops
203− }
204−
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
212− i_alt = i_t <-> i_b
213− in display_ops_for_image i == display_ops_for_image i_alt
214−
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
265 ]
186 ]
vty.cabal+11−25
@@ -418,17 +418,21 @@ test-suite verify-parse-terminfo-caps
418 utf8-string >= 0.3 && < 0.4,
418 utf8-string >= 0.3 && < 0.4,
419 vector >= 0.7
419 vector >= 0.7
420
420
421−
422−test-suite verify-picture-ops
421+test-suite verify-simple-span-generation
423 default-language: Haskell2010
422 default-language: Haskell2010
424
423
425 type: detailed-0.9
424 type: detailed-0.9
426
425
427 hs-source-dirs: test
426 hs-source-dirs: test
428
427
429− test-module: VerifyPictureOps
428+ test-module: VerifySimpleSpanGeneration
430
429
431 other-modules: Verify
430 other-modules: Verify
431+ Verify.Graphics.Vty.Attributes
432+ Verify.Graphics.Vty.DisplayRegion
433+ Verify.Graphics.Vty.Picture
434+ Verify.Graphics.Vty.Image
435+ Verify.Graphics.Vty.Span
432
436
433 build-depends: vty,
437 build-depends: vty,
434 Cabal == 1.17.*,
438 Cabal == 1.17.*,
@@ -438,26 +442,20 @@ test-suite verify-picture-ops
438 bytestring,
442 bytestring,
439 containers,
443 containers,
440 deepseq >= 1.1 && < 1.4,
444 deepseq >= 1.1 && < 1.4,
441− ghc-prim,
442− lens,
443 mtl >= 1.1.1.0 && < 2.2,
445 mtl >= 1.1.1.0 && < 2.2,
444− parallel >= 2.2 && < 3.3,
445− parsec >= 2 && < 4,
446− terminfo >= 0.3 && < 0.4,
447 text >= 0.11.3,
446 text >= 0.11.3,
448 unix,
447 unix,
449 utf8-string >= 0.3 && < 0.4,
448 utf8-string >= 0.3 && < 0.4,
450 vector >= 0.7
449 vector >= 0.7
451
450
452−
453−test-suite verify-picture-to-span
451+test-suite verify-crop-span-generation
454 default-language: Haskell2010
452 default-language: Haskell2010
455
453
456 type: detailed-0.9
454 type: detailed-0.9
457
455
458 hs-source-dirs: test
456 hs-source-dirs: test
459
457
460− test-module: VerifyPictureToSpan
458+ test-module: VerifyCropSpanGeneration
461
459
462 other-modules: Verify
460 other-modules: Verify
463 Verify.Graphics.Vty.Attributes
461 Verify.Graphics.Vty.Attributes
@@ -474,26 +472,20 @@ test-suite verify-picture-to-span
474 bytestring,
472 bytestring,
475 containers,
473 containers,
476 deepseq >= 1.1 && < 1.4,
474 deepseq >= 1.1 && < 1.4,
477− ghc-prim,
478− lens,
479 mtl >= 1.1.1.0 && < 2.2,
475 mtl >= 1.1.1.0 && < 2.2,
480− parallel >= 2.2 && < 3.3,
481− parsec >= 2 && < 4,
482− terminfo >= 0.3 && < 0.4,
483 text >= 0.11.3,
476 text >= 0.11.3,
484 unix,
477 unix,
485 utf8-string >= 0.3 && < 0.4,
478 utf8-string >= 0.3 && < 0.4,
486 vector >= 0.7
479 vector >= 0.7
487−
488
480
489−test-suite verify-span-ops
481+test-suite verify-layers-span-generation
490 default-language: Haskell2010
482 default-language: Haskell2010
491
483
492 type: detailed-0.9
484 type: detailed-0.9
493
485
494 hs-source-dirs: test
486 hs-source-dirs: test
495
487
496− test-module: VerifySpanOps
488+ test-module: VerifyLayersSpanGeneration
497
489
498 other-modules: Verify
490 other-modules: Verify
499 Verify.Graphics.Vty.Attributes
491 Verify.Graphics.Vty.Attributes
@@ -510,17 +502,11 @@ test-suite verify-span-ops
510 bytestring,
502 bytestring,
511 containers,
503 containers,
512 deepseq >= 1.1 && < 1.4,
504 deepseq >= 1.1 && < 1.4,
513− ghc-prim,
514− lens,
515 mtl >= 1.1.1.0 && < 2.2,
505 mtl >= 1.1.1.0 && < 2.2,
516− parallel >= 2.2 && < 3.3,
517− parsec >= 2 && < 4,
518− terminfo >= 0.3 && < 0.4,
519 text >= 0.11.3,
506 text >= 0.11.3,
520 unix,
507 unix,
521 utf8-string >= 0.3 && < 0.4,
508 utf8-string >= 0.3 && < 0.4,
522 vector >= 0.7
509 vector >= 0.7
523−
524
510
525test-suite verify-utf8-width
511test-suite verify-utf8-width
526 default-language: Haskell2010
512 default-language: Haskell2010