git.iko.soy/typeable/elm-ui
on master help sign in
compare numbers by rounding || flooring
79df3d1Matthew Griffith
tests/src/Testable/Element.elm+39−63
@@ -1040,6 +1040,10 @@ onLeft element =
1040 }
1040 }
1041
1041
1042
1042
1043+compare x vs y =
1044+ vs (round x) (round y) || vs (floor x) (floor y)
1045+
1046+
1043{-| -}
1047{-| -}
1044inFront : Testable.Element msg -> Testable.Attr msg
1048inFront : Testable.Element msg -> Testable.Attr msg
1045inFront element =
1049inFront element =
@@ -1048,39 +1052,42 @@ inFront element =
1048 , element = element
1052 , element = element
1049 , label = "inFront"
1053 , label = "inFront"
1050 , test =
1054 , test =
1051− \found _ ->
1055+ withinHelper
1052− let
1056+ }
1053− horizontalCheck =
1054− if found.self.bbox.width > found.parent.bbox.width then
1055− [ (found.self.bbox.right <= found.parent.bbox.right)
1056− || (found.self.bbox.left >= found.parent.bbox.left)
1057− ]
1058
1057
1059− else
1060− [ found.self.bbox.right <= found.parent.bbox.right
1061− , found.self.bbox.left >= found.parent.bbox.left
1062− ]
1063
1058
1064− verticalCheck =
1059+withinHelper found _ =
1060+ let
1061+ horizontalCheck =
1065− if found.self.bbox.width > found.parent.bbox.width then
1062+ if found.self.bbox.width > found.parent.bbox.width then
1066− [ (found.self.bbox.top >= found.parent.bbox.top)
1063+ [ compare found.self.bbox.right (<=) found.parent.bbox.right
1067− || (found.self.bbox.bottom <= found.parent.bbox.bottom)
1064+ || compare found.self.bbox.left (>=) found.parent.bbox.left
1068− ]
1065+ ]
1069
1066
1070− else
1067+ else
1068+ [ compare found.self.bbox.right (<=) found.parent.bbox.right
1069+ , compare found.self.bbox.left (>=) found.parent.bbox.left
1070+ ]
1071+
1072+ verticalCheck =
1073+ if found.self.bbox.width > found.parent.bbox.width then
1074+ [ compare found.self.bbox.top (>=) found.parent.bbox.top
1075+ || compare found.self.bbox.bottom (<=) found.parent.bbox.bottom
1076+ ]
1077+
1078+ else
1071− [ found.self.bbox.top >= found.parent.bbox.top
1079+ [ compare found.self.bbox.top (>=) found.parent.bbox.top
1072− , found.self.bbox.bottom <= found.parent.bbox.bottom
1080+ , compare found.self.bbox.bottom (<=) found.parent.bbox.bottom
1073− ]
1081+ ]
1074− in
1082+ in
1075− Expect.true "within the confines of the parent"
1083+ Expect.true "within the confines of the parent"
1076− (List.all ((==) True)
1084+ (List.all ((==) True)
1077− (List.concat
1085+ (List.concat
1078− [ horizontalCheck
1086+ [ horizontalCheck
1079− , verticalCheck
1087+ , verticalCheck
1080− ]
1088+ ]
1081− )
1082− )
1089+ )
1083− }
1090+ )
1084
1091
1085
1092
1086{-| -}
1093{-| -}
@@ -1089,38 +1096,7 @@ behindContent element =
1089 Testable.Nearby
1096 Testable.Nearby
1090 { location = Testable.Behind
1097 { location = Testable.Behind
1091 , element = element
1098 , element = element
1092− , label = "behind"
1099+ , label = "behindContent"
1093 , test =
1100 , test =
1094− \found _ ->
1101+ withinHelper
1095− let
1096− horizontalCheck =
1097− if found.self.bbox.width > found.parent.bbox.width then
1098− [ (found.self.bbox.right <= found.parent.bbox.right)
1099− || (found.self.bbox.left >= found.parent.bbox.left)
1100− ]
1101−
1102− else
1103− [ found.self.bbox.right <= found.parent.bbox.right
1104− , found.self.bbox.left >= found.parent.bbox.left
1105− ]
1106−
1107− verticalCheck =
1108− if found.self.bbox.width > found.parent.bbox.width then
1109− [ (found.self.bbox.top >= found.parent.bbox.top)
1110− || (found.self.bbox.bottom <= found.parent.bbox.bottom)
1111− ]
1112−
1113− else
1114− [ found.self.bbox.top >= found.parent.bbox.top
1115− , found.self.bbox.bottom <= found.parent.bbox.bottom
1116− ]
1117− in
1118− Expect.true "within the confines of the parent"
1119− (List.all ((==) True)
1120− (List.concat
1121− [ horizontalCheck
1122− , verticalCheck
1123− ]
1124− )
1125− )
1126 }
1102 }