on master help sign in
add initial test for layered span generation
2a7fce5Corey O'Connor
src/Graphics/Vty/Picture.hs+2−1
@@ -37,7 +37,8 @@ pic_for_image i = Picture
37 , pic_background = ClearBackground
37 , pic_background = ClearBackground
38 }
38 }
39
39
40−-- | Create a picture for display with the given layers.
40+-- | Create a picture for display with the given layers. Ordered top to bottom.
41+--
41-- The first image is the top layer.
42-- The first image is the top layer.
42pic_for_layers :: [Image] -> Picture
43pic_for_layers :: [Image] -> Picture
43pic_for_layers is = Picture
44pic_for_layers is = Picture
test/Verify/Graphics/Vty/Span.hs+7
@@ -28,3 +28,10 @@ verify_all_spans_have_width i spans w
28 ++ (concatMap ((++ "\n") . show)) v
28 ++ (concatMap ((++ "\n") . show)) v
29 }
29 }
30
30
31+verify_ops_equality i_ops i_alt_ops =
32+ if i_ops == i_alt_ops
33+ then succeeded
34+ else failed { reason = "ops for alternate image " ++ show i_alt_ops
35+ ++ " are not the same as " ++ show i_ops
36+ }
37+
test/VerifyCropSpanGeneration.hs+1−5
@@ -61,11 +61,7 @@ crop_right_and_left_rejoined_equivalence stack = image_width (stack_image stack)
61 i_alt = i_l <|> i_r
61 i_alt = i_l <|> i_r
62 i_ops = display_ops_for_image i
62 i_ops = display_ops_for_image i
63 i_alt_ops = display_ops_for_image i_alt
63 i_alt_ops = display_ops_for_image i_alt
64− in if i_ops == i_alt_ops
64+ in verify_ops_equality 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
65
70crop_top_and_bottom_rejoined_equivalence :: SingleAttrSingleSpanStack -> Property
66crop_top_and_bottom_rejoined_equivalence :: SingleAttrSingleSpanStack -> Property
71crop_top_and_bottom_rejoined_equivalence stack = image_height (stack_image stack) `mod` 2 == 0 ==>
67crop_top_and_bottom_rejoined_equivalence stack = image_height (stack_image stack) `mod` 2 == 0 ==>
test/VerifyLayersSpanGeneration.hs+13−1
@@ -14,7 +14,19 @@ import Verify
14
14
15import qualified Data.Vector as Vector
15import qualified Data.Vector as Vector
16
16
17+larger_horiz_span_occlusion :: SingleRowSingleAttrImage -> SingleRowSingleAttrImage -> Result
18+larger_horiz_span_occlusion row_0 row_1 =
19+ let i_0 = row_image row_0
20+ i_1 = row_image row_1
21+ (i_larger, i_smaller) = if image_width i_0 > image_width i_1 then (i_0, i_1) else (i_1, i_0)
22+ expected_ops = display_ops_for_image i_larger
23+ p = pic_for_layers [i_larger, i_smaller]
24+ ops = display_ops_for_pic p $ DisplayRegion (image_width i_larger) (image_height i_larger)
25+ in verify_ops_equality expected_ops ops
26+
17tests :: IO [Test]
27tests :: IO [Test]
18tests = return
28tests = return
29+ [ verify "a larger horiz span occludes a smaller span on a lower layer"
30+ larger_horiz_span_occlusion
19− [ ]
31+ ]
20
32