1{-# LANGUAGE ScopedTypeVariables #-}
2module VerifyImageOps where
4import Graphics.Vty.Attributes
5import Verify.Graphics.Vty.Image
11two_sw_horiz_concat :: SingleColumnChar -> SingleColumnChar -> Bool
12two_sw_horiz_concat (SingleColumnChar c1) (SingleColumnChar c2) =
13 image_width (char def_attr c1 <|> char def_attr c2) == 2
15many_sw_horiz_concat :: [SingleColumnChar] -> Bool
16many_sw_horiz_concat cs =
17 let chars = [ char | SingleColumnChar char <- cs ]
18 l = fromIntegral $ length cs
19 in image_width ( horiz_cat $ map (char def_attr) chars ) == l
21two_sw_vert_concat :: SingleColumnChar -> SingleColumnChar -> Bool
22two_sw_vert_concat (SingleColumnChar c1) (SingleColumnChar c2) =
23 image_height (char def_attr c1 <-> char def_attr c2) == 2
25horiz_concat_sw_assoc :: SingleColumnChar -> SingleColumnChar -> SingleColumnChar -> Bool
26horiz_concat_sw_assoc (SingleColumnChar c0) (SingleColumnChar c1) (SingleColumnChar c2) =
27 (char def_attr c0 <|> char def_attr c1) <|> char def_attr c2
29 char def_attr c0 <|> (char def_attr c1 <|> char def_attr c2)
31two_dw_horiz_concat :: DoubleColumnChar -> DoubleColumnChar -> Bool
32two_dw_horiz_concat (DoubleColumnChar c1) (DoubleColumnChar c2) =
33 image_width (char def_attr c1 <|> char def_attr c2) == 4
35many_dw_horiz_concat :: [DoubleColumnChar] -> Bool
36many_dw_horiz_concat cs =
37 let chars = [ char | DoubleColumnChar char <- cs ]
38 l = fromIntegral $ length cs
39 in image_width ( horiz_cat $ map (char def_attr) chars ) == l * 2
41two_dw_vert_concat :: DoubleColumnChar -> DoubleColumnChar -> Bool
42two_dw_vert_concat (DoubleColumnChar c1) (DoubleColumnChar c2) =
43 image_height (char def_attr c1 <-> char def_attr c2) == 2
45horiz_concat_dw_assoc :: DoubleColumnChar -> DoubleColumnChar -> DoubleColumnChar -> Bool
46horiz_concat_dw_assoc (DoubleColumnChar c0) (DoubleColumnChar c1) (DoubleColumnChar c2) =
47 (char def_attr c0 <|> char def_attr c1) <|> char def_attr c2
49 char def_attr c0 <|> (char def_attr c1 <|> char def_attr c2)
51vert_contat_single_row :: NonEmptyList SingleRowSingleAttrImage -> Bool
52vert_contat_single_row (NonEmpty stack) =
53 let expected_height :: Word = fromIntegral $ length stack
54 stack_image = vert_cat [ i | SingleRowSingleAttrImage { row_image = i } <- stack ]
55 in image_height stack_image == expected_height
57disjoint_height_horiz_join :: NonEmptyList SingleRowSingleAttrImage
58 -> NonEmptyList SingleRowSingleAttrImage
60disjoint_height_horiz_join (NonEmpty stack_0) (NonEmpty stack_1) =
61 let expected_height :: Word = fromIntegral $ max (length stack_0) (length stack_1)
62 stack_image_0 = vert_cat [ i | SingleRowSingleAttrImage { row_image = i } <- stack_0 ]
63 stack_image_1 = vert_cat [ i | SingleRowSingleAttrImage { row_image = i } <- stack_1 ]
64 in image_height (stack_image_0 <|> stack_image_1) == expected_height
67disjoint_height_horiz_join_bg_fill :: NonEmptyList SingleRowSingleAttrImage
68 -> NonEmptyList SingleRowSingleAttrImage
70disjoint_height_horiz_join_bg_fill (NonEmpty stack_0) (NonEmpty stack_1) =
71 let stack_image_0 = vert_cat [ i | SingleRowSingleAttrImage { row_image = i } <- stack_0 ]
72 stack_image_1 = vert_cat [ i | SingleRowSingleAttrImage { row_image = i } <- stack_1 ]
73 image = stack_image_0 <|> stack_image_1
74 expected_height = image_height image
76 HorizJoin {} -> ( expected_height == (image_height $ part_left image) )
78 ( expected_height == (image_height $ part_right image) )
81disjoint_width_vert_join :: NonEmptyList SingleRowSingleAttrImage
82 -> NonEmptyList SingleRowSingleAttrImage
84disjoint_width_vert_join (NonEmpty stack_0) (NonEmpty stack_1) =
85 let expected_width = maximum $ map image_width (stack_0_images ++ stack_1_images)
86 stack_0_images = [ i | SingleRowSingleAttrImage { row_image = i } <- stack_0 ]
87 stack_1_images = [ i | SingleRowSingleAttrImage { row_image = i } <- stack_1 ]
88 stack_0_image = vert_cat stack_0_images
89 stack_1_image = vert_cat stack_1_images
90 image = stack_0_image <-> stack_1_image
91 in image_width image == expected_width
93disjoint_width_vert_join_bg_fill :: NonEmptyList SingleRowSingleAttrImage
94 -> NonEmptyList SingleRowSingleAttrImage
96disjoint_width_vert_join_bg_fill (NonEmpty stack_0) (NonEmpty stack_1) =
97 let expected_width = maximum $ map image_width (stack_0_images ++ stack_1_images)
98 stack_0_images = [ i | SingleRowSingleAttrImage { row_image = i } <- stack_0 ]
99 stack_1_images = [ i | SingleRowSingleAttrImage { row_image = i } <- stack_1 ]
100 stack_0_image = vert_cat stack_0_images
101 stack_1_image = vert_cat stack_1_images
102 image = stack_0_image <-> stack_1_image
104 VertJoin {} -> ( expected_width == (image_width $ part_top image) )
106 ( expected_width == (image_width $ part_bottom image) )
111 [ verify "two_sw_horiz_concat" two_sw_horiz_concat
112 , verify "many_sw_horiz_concat" many_sw_horiz_concat
113 , verify "two_sw_vert_concat" two_sw_vert_concat
114 , verify "horiz_concat_sw_assoc" horiz_concat_sw_assoc
115 , verify "many_dw_horiz_concat" many_dw_horiz_concat
116 , verify "two_dw_horiz_concat" two_dw_horiz_concat
117 , verify "two_dw_vert_concat" two_dw_vert_concat
118 , verify "horiz_concat_dw_assoc" horiz_concat_dw_assoc
119 , verify "single row vert concats to correct height" vert_contat_single_row
120 , verify "disjoint_height_horiz_join" disjoint_height_horiz_join
121 , verify "disjoint_height_horiz_join BG fill" disjoint_height_horiz_join_bg_fill
122 , verify "disjoint_width_vert_join" disjoint_width_vert_join
123 , verify "disjoint_width_vert_join BG fill" disjoint_width_vert_join_bg_fill
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list