Commit d87ef0cb authored by Steffen Michels's avatar Steffen Michels

add approx equal property

parent 3ee11e60
...@@ -53,3 +53,5 @@ limitNrOfRecFieldValues :: !(Map (TypeName, RecFieldName) Int) !p -> Property | ...@@ -53,3 +53,5 @@ limitNrOfRecFieldValues :: !(Map (TypeName, RecFieldName) Int) !p -> Property |
instance ~ Bool instance ~ Bool
instance ~ Property instance ~ Property
approxEqual :: !a !a !a -> Property | abs, Ord, -, genShow{|*|}, JSONEncode{|*|} a
...@@ -216,3 +216,8 @@ where ...@@ -216,3 +216,8 @@ where
instance ~ Property instance ~ Property
where ~ (Prop n p) = Prop ("~" +++ n) (\rs r = let r` = testAnalysis r (p rs r) in [{r` & res = ~r`.res}]) where ~ (Prop n p) = Prop ("~" +++ n) (\rs r = let r` = testAnalysis r (p rs r) in [{r` & res = ~r`.res}])
approxEqual :: !a !a !a -> Property | abs, Ord, -, genShow{|*|}, JSONEncode{|*|} a
approxEqual err x y = Prop "approximately equals"
(affirm (\x y -> abs (x - y) <= err)
(Other $ concat ["approximately equals (error = ", toString $ toJSON err, ")"]) x y)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment