[commit: packages/time] master: prop_name helper for defining named properties. (c8bba9b)

git at git.haskell.org git at git.haskell.org
Fri Jan 23 22:59:17 UTC 2015


Repository : ssh://git@git.haskell.org/time

On branch  : master
Link       : http://git.haskell.org/packages/time.git/commitdiff/c8bba9b75c9ea49bfa955a2c5913b5322446923d

>---------------------------------------------------------------

commit c8bba9b75c9ea49bfa955a2c5913b5322446923d
Author: Bjorn Buckwalter <bjorn.buckwalter at gmail.com>
Date:   Sat Jan 17 17:10:08 2009 -0800

    prop_name helper for defining named properties.
    
    darcs-hash:20090118011008-03283-d383aaaec1c96d8ca8a0f23ca2464d29e6e7d428


>---------------------------------------------------------------

c8bba9b75c9ea49bfa955a2c5913b5322446923d
 test/TestParseTime.hs | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/test/TestParseTime.hs b/test/TestParseTime.hs
index 8e313ba..11b8787 100644
--- a/test/TestParseTime.hs
+++ b/test/TestParseTime.hs
@@ -124,14 +124,17 @@ prop_fromSundayStartWeek d =
 -- * format and parse 
 --
 
+-- | Helper for defining named properties.
+prop_named :: (Arbitrary t, Show t, Testable a)
+           => String -> (FormatString s -> t -> a) -> String -> FormatString s -> NamedProperty
+prop_named name prop typeName f = (name ++ " " ++ typeName ++ " " ++ show f, property (prop f))
+
 prop_parse_format :: (Eq t, FormatTime t, ParseTime t) => FormatString t -> t -> Bool
 prop_parse_format (FormatString f) t = parse f (format f t) == Just t
 
 prop_parse_format_named :: (Arbitrary t, Eq t, Show t, FormatTime t, ParseTime t) 
                            => String -> FormatString t -> NamedProperty
-prop_parse_format_named typeName f = 
-    ("prop_parse_format " ++ typeName ++ " " ++ show f, 
-     property (prop_parse_format f))
+prop_parse_format_named = prop_named "prop_parse_format" prop_parse_format
 
 prop_format_parse_format :: (FormatTime t, ParseTime t) => FormatString t -> t -> Bool
 prop_format_parse_format (FormatString f) t = 
@@ -139,9 +142,7 @@ prop_format_parse_format (FormatString f) t =
 
 prop_format_parse_format_named :: (Arbitrary t, Show t, FormatTime t, ParseTime t) 
                                   => String -> FormatString t -> NamedProperty
-prop_format_parse_format_named typeName f = 
-    ("prop_format_parse_format " ++ typeName ++ " " ++ show f, 
-     property (prop_format_parse_format f))
+prop_format_parse_format_named = prop_named "prop_format_parse_format" prop_format_parse_format
 
 --
 -- * crashes in parse
@@ -166,9 +167,7 @@ prop_no_crash_bad_input fs@(FormatString f) (Input s) = property $
   where 
 prop_no_crash_bad_input_named :: (Eq t, ParseTime t)
                                  => String -> FormatString t -> NamedProperty
-prop_no_crash_bad_input_named typeName f = 
-    ("prop_no_crash_bad_input " ++ typeName ++ " " ++ show f, 
-     property (prop_no_crash_bad_input f))
+prop_no_crash_bad_input_named = prop_named "prop_no_crash_bad_input" prop_no_crash_bad_input
 
 --
 --



More information about the ghc-commits mailing list