[commit: packages/time] format-widths, ghc, improve-leapseconds, master, posix-perf, tasty, wip/travis: TestParseTime: more tests (c732e4d)

git at git.haskell.org git at git.haskell.org
Fri Apr 21 16:52:25 UTC 2017


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

On branches: format-widths,ghc,improve-leapseconds,master,posix-perf,tasty,wip/travis
Link       : http://git.haskell.org/packages/time.git/commitdiff/c732e4d16d58ec1de790dc60afd7475c96641d89

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

commit c732e4d16d58ec1de790dc60afd7475c96641d89
Author: Ashley Yakeley <ashley at yakeley.org>
Date:   Sun Aug 17 19:39:51 2014 -0700

    TestParseTime: more tests


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

c732e4d16d58ec1de790dc60afd7475c96641d89
 Test/TestParseTime.hs | 36 ++++++++++++++++++++++++------------
 1 file changed, 24 insertions(+), 12 deletions(-)

diff --git a/Test/TestParseTime.hs b/Test/TestParseTime.hs
index e53a016..97acfb6 100644
--- a/Test/TestParseTime.hs
+++ b/Test/TestParseTime.hs
@@ -63,25 +63,37 @@ readTest expected target = let
     name = show target
     in pureTest name result
 
+readTestsParensSpaces :: forall a. (Eq a,Show a,Read a) => a -> String -> Test
+readTestsParensSpaces expected target = testGroup target
+    [
+    readTest [(expected,"")] $ target,
+    readTest [(expected,"")] $ "("++target++")",
+    readTest [(expected,"")] $ " ("++target++")",
+    readTest [(expected," ")] $ " ( "++target++" ) ",
+    readTest [(expected," ")] $ " (( "++target++" )) ",
+    readTest ([] :: [(a,String)]) $ "("++target,
+    readTest [(expected,")")] $ ""++target++")",
+    readTest [(expected,"")] $ "(("++target++"))",
+    readTest [(expected," ")] $ "  (   (     "++target++"   )  ) "
+    ] where
+
 readOtherTypesTest :: Test
 readOtherTypesTest = testGroup "read other types"
     [
-    readTest [(3,"")] "3",
-    readTest [(3,"")] "(3)",
-    readTest [(3,"")] " (3)",
-    readTest [(3," ")] " ( 3 ) ",
-    readTest [(3," ")] " (( 3 )) ",
-    readTest [("a","")] "(\"a\")",
-    readTest ([] :: [(String,String)]) "(\"a\"",
-    readTest [("a",")")] "\"a\")",
-    readTest [("a","")] "((\"a\"))",
-    readTest [("a"," ")] "  (   (     \"a\"   )  ) "
-    ] where
+    readTestsParensSpaces 3 "3",
+    readTestsParensSpaces "a" "\"a\""
+    ]
 
 readTests :: Test
 readTests = testGroup "read times"
     [
-    ]
+    readTestsParensSpaces testDay "1912-07-08",
+    readTestsParensSpaces testDay "1912-7-8",
+    readTestsParensSpaces testTimeOfDay "08:04:02",
+    readTestsParensSpaces testTimeOfDay "8:4:2"
+    ] where
+    testDay = fromGregorian 1912 7 8
+    testTimeOfDay = TimeOfDay 8 4 2
 
 simpleFormatTests :: Test
 simpleFormatTests = testGroup "simple"



More information about the ghc-commits mailing list