on master help sign in
split the VerifySpanOps test into two. add boilerplate for layers tests
commit8131ac30d8565f8a18a470dae9b93b44b0dfd825 authorCorey O'Connor <corey@ooyala.com> dateThu 15 Aug 2013, 13:47 (13 years ago) parent838dd51
6 files changed+128−123
test/VerifyCropSpanGeneration.hs+96 test/VerifyLayersSpanGeneration.hs+20 test/VerifyPictureOps.hs−8 test/VerifyPictureToSpan.hs−10 test/VerifySpanOps.hs → test/VerifySimpleSpanGeneration.hs+1−80 vty.cabal+11−25
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 @@
11{-# LANGUAGE DisambiguateRecordFields #-}
22{-# LANGUAGE NamedFieldPuns #-}
3−module VerifySpanOps where
3+module VerifySimpleSpanGeneration where
44
55import Verify.Graphics.Vty.DisplayRegion
66import Verify.Graphics.Vty.Image
@@ -149,69 +149,6 @@ single_attr_single_span_stack_op_coverage stack =
149149 ops = display_ops_for_pic p (region_for_window w)
150150 in verify_all_spans_have_width (stack_image stack) ops (stack_width stack)
151151
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−
215152image_coverage_matches_bounds :: Image -> Result
216153image_coverage_matches_bounds i =
217154 let p = pic_for_image i
@@ -229,9 +166,6 @@ tests = return
229166 , verify "horiz span image is not cropped when window size == size of image [height]" horiz_span_image_and_equal_window_1
230167 , verify "horiz span image is not cropped when window size < size of image [width]" horiz_span_image_and_lesser_window_0
231168 , 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
235169 , verify "first span op is always to set the text attribute" first_span_op_sets_attr
236170 , verify "a stack of single attr text spans should define content for all the columns [output region == size of stack]"
237171 single_attr_single_span_stack_op_coverage
@@ -247,19 +181,6 @@ tests = return
247181 single_attr_single_span_stack_cropped_4
248182 , verify "single attr text span <-> single attr text span display cropped. [height]"
249183 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
263184 , verify "an arbitrary image when rendered to a window of the same size will cover the entire window"
264185 image_coverage_matches_bounds
265186 ]
vty.cabal+11−25
@@ -418,17 +418,21 @@ test-suite verify-parse-terminfo-caps
418418 utf8-string >= 0.3 && < 0.4,
419419 vector >= 0.7
420420
421−
422−test-suite verify-picture-ops
421+test-suite verify-simple-span-generation
423422 default-language: Haskell2010
424423
425424 type: detailed-0.9
426425
427426 hs-source-dirs: test
428427
429− test-module: VerifyPictureOps
428+ test-module: VerifySimpleSpanGeneration
430429
431430 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
432436
433437 build-depends: vty,
434438 Cabal == 1.17.*,
@@ -438,26 +442,20 @@ test-suite verify-picture-ops
438442 bytestring,
439443 containers,
440444 deepseq >= 1.1 && < 1.4,
441− ghc-prim,
442− lens,
443445 mtl >= 1.1.1.0 && < 2.2,
444− parallel >= 2.2 && < 3.3,
445− parsec >= 2 && < 4,
446− terminfo >= 0.3 && < 0.4,
447446 text >= 0.11.3,
448447 unix,
449448 utf8-string >= 0.3 && < 0.4,
450449 vector >= 0.7
451450
452−
453−test-suite verify-picture-to-span
451+test-suite verify-crop-span-generation
454452 default-language: Haskell2010
455453
456454 type: detailed-0.9
457455
458456 hs-source-dirs: test
459457
460− test-module: VerifyPictureToSpan
458+ test-module: VerifyCropSpanGeneration
461459
462460 other-modules: Verify
463461 Verify.Graphics.Vty.Attributes
@@ -474,26 +472,20 @@ test-suite verify-picture-to-span
474472 bytestring,
475473 containers,
476474 deepseq >= 1.1 && < 1.4,
477− ghc-prim,
478− lens,
479475 mtl >= 1.1.1.0 && < 2.2,
480− parallel >= 2.2 && < 3.3,
481− parsec >= 2 && < 4,
482− terminfo >= 0.3 && < 0.4,
483476 text >= 0.11.3,
484477 unix,
485478 utf8-string >= 0.3 && < 0.4,
486479 vector >= 0.7
487−
488480
489−test-suite verify-span-ops
481+test-suite verify-layers-span-generation
490482 default-language: Haskell2010
491483
492484 type: detailed-0.9
493485
494486 hs-source-dirs: test
495487
496− test-module: VerifySpanOps
488+ test-module: VerifyLayersSpanGeneration
497489
498490 other-modules: Verify
499491 Verify.Graphics.Vty.Attributes
@@ -510,17 +502,11 @@ test-suite verify-span-ops
510502 bytestring,
511503 containers,
512504 deepseq >= 1.1 && < 1.4,
513− ghc-prim,
514− lens,
515505 mtl >= 1.1.1.0 && < 2.2,
516− parallel >= 2.2 && < 3.3,
517− parsec >= 2 && < 4,
518− terminfo >= 0.3 && < 0.4,
519506 text >= 0.11.3,
520507 unix,
521508 utf8-string >= 0.3 && < 0.4,
522509 vector >= 0.7
523−
524510
525511test-suite verify-utf8-width
526512 default-language: Haskell2010