[commit: packages/time] ghc, master: test: fix most failures on 32 bit (50265a9)
git at git.haskell.org
git at git.haskell.org
Fri Apr 21 16:57:43 UTC 2017
Repository : ssh://git@git.haskell.org/time
On branches: ghc,master
Link : http://git.haskell.org/packages/time.git/commitdiff/50265a94bf83fb8ed10fbc2a2dee6b9015e1d49a
>---------------------------------------------------------------
commit 50265a94bf83fb8ed10fbc2a2dee6b9015e1d49a
Author: Ashley Yakeley <ashley at localhost.localdomain>
Date: Sat Mar 11 09:43:13 2017 -0800
test: fix most failures on 32 bit
>---------------------------------------------------------------
50265a94bf83fb8ed10fbc2a2dee6b9015e1d49a
test/main/Main.hs | 6 +-----
test/unix/Main.hs | 6 +-----
test/unix/Test/Format/Format.hs | 11 ++++++++++-
3 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/test/main/Main.hs b/test/main/Main.hs
index 5c40256..2d02b4a 100644
--- a/test/main/Main.hs
+++ b/test/main/Main.hs
@@ -45,8 +45,4 @@ tests = testGroup "Time" [
]
main :: IO ()
-main = do
- if (toRational (1000000000000 :: CTime)) /= (1000000000000 :: Rational)
- then putStrLn "WARNING: Some tests will incorrectly fail due to a 32-bit time_t C type."
- else return ()
- defaultMain tests
+main = defaultMain tests
diff --git a/test/unix/Main.hs b/test/unix/Main.hs
index f2bac52..eac8ac0 100644
--- a/test/unix/Main.hs
+++ b/test/unix/Main.hs
@@ -17,8 +17,4 @@ tests = testGroup "Time" [
]
main :: IO ()
-main = do
- if (toRational (1000000000000 :: CTime)) /= (1000000000000 :: Rational)
- then putStrLn "WARNING: Some tests will incorrectly fail due to a 32-bit time_t C type."
- else return ()
- defaultMain tests
+main = defaultMain tests
diff --git a/test/unix/Test/Format/Format.hs b/test/unix/Test/Format/Format.hs
index 1f8ec4a..753371c 100644
--- a/test/unix/Test/Format/Format.hs
+++ b/test/unix/Test/Format/Format.hs
@@ -56,7 +56,16 @@ times :: Gen UTCTime
times = do
day <- choose (-25000,75000)
time <- return midnight
- return $ localTimeToUTC utc $ LocalTime (ModifiedJulianDay day) time
+ let
+ -- verify that the created time can fit in the local CTime
+ localT = LocalTime (ModifiedJulianDay day) time
+ utcT = localTimeToUTC utc localT
+ secondsInteger = truncate (utcTimeToPOSIXSeconds utcT)
+ CTime secondsCTime = fromInteger secondsInteger
+ secondsInteger' = toInteger secondsCTime
+ if secondsInteger == secondsInteger'
+ then return utcT
+ else times
padN :: Int -> Char -> String -> String
padN n _ s | n <= (length s) = s
More information about the ghc-commits
mailing list