on master help sign in
add initial test for layered span generation
commit2a7fce5bcc72d320ae6f09f9715e56536f8ec604 authorCorey O'Connor <corey@ooyala.com> dateThu 15 Aug 2013, 14:05 (13 years ago) parent8131ac3
4 files changed+23−7
src/Graphics/Vty/Picture.hs+2−1 test/Verify/Graphics/Vty/Span.hs+7 test/VerifyCropSpanGeneration.hs+1−5 test/VerifyLayersSpanGeneration.hs+13−1
src/Graphics/Vty/Picture.hs+2−1
@@ -37,7 +37,8 @@ pic_for_image i = Picture
3737 , pic_background = ClearBackground
3838 }
3939
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+--
4142-- The first image is the top layer.
4243pic_for_layers :: [Image] -> Picture
4344pic_for_layers is = Picture
test/Verify/Graphics/Vty/Span.hs+7
@@ -28,3 +28,10 @@ verify_all_spans_have_width i spans w
2828 ++ (concatMap ((++ "\n") . show)) v
2929 }
3030
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)
6161 i_alt = i_l <|> i_r
6262 i_ops = display_ops_for_image i
6363 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− }
64+ in verify_ops_equality i_ops i_alt_ops
6965
7066crop_top_and_bottom_rejoined_equivalence :: SingleAttrSingleSpanStack -> Property
7167crop_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
1414
1515import qualified Data.Vector as Vector
1616
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+
1727tests :: IO [Test]
1828tests = return
19− [ ]
29+ [ verify "a larger horiz span occludes a smaller span on a lower layer"
30+ larger_horiz_span_occlusion
31+ ]
2032