[commit: packages/base] master: Port ThreadDelay001 to the "time" library (5fcdb2a)

git at git.haskell.org git
Sat Oct 5 16:30:23 UTC 2013


Repository : ssh://git at git.haskell.org/base

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/5fcdb2a6059617cb2ffd53c4882e1b16fb6a8037/base

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

commit 5fcdb2a6059617cb2ffd53c4882e1b16fb6a8037
Author: Reid Barton <rwbarton at gmail.com>
Date:   Tue Oct 1 21:10:49 2013 -0400

    Port ThreadDelay001 to the "time" library
    
    ... as "old-time" isn't built when cross-compiling.
    
    Issue #8395.
    
    Signed-off-by: Austin Seipp <aseipp at pobox.com>


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

5fcdb2a6059617cb2ffd53c4882e1b16fb6a8037
 tests/Concurrent/ThreadDelay001.hs |   11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/tests/Concurrent/ThreadDelay001.hs b/tests/Concurrent/ThreadDelay001.hs
index 36aa152..3b0f806 100644
--- a/tests/Concurrent/ThreadDelay001.hs
+++ b/tests/Concurrent/ThreadDelay001.hs
@@ -6,22 +6,19 @@ module Main (main) where
 
 import Control.Concurrent
 import Control.Monad
-import System.Time
+import Data.Time
 
 main :: IO ()
 main = mapM_ delay (0 : take 7 (iterate (*5) 100))
 
 delay :: Int -> IO ()
 delay n = do
-  tS <- getClockTime
+  tS <- getCurrentTime
   threadDelay n
-  tE <- getClockTime
+  tE <- getCurrentTime
 
   let req = fromIntegral n * 10 ^ (6 :: Int)
-      obs = case normalizeTimeDiff (diffClockTimes tE tS) of
-                TimeDiff 0 0 0 0 0 s ps -> 10 ^ (12 :: Int) * fromIntegral s + ps
-                td ->
-                    error ("Bad TimeDiff: " ++ show td)
+      obs = floor (diffUTCTime tE tS * 10 ^ (12 :: Int))
       diff = obs - req
       diff' :: Double
       diff' = fromIntegral diff /  10 ^ (12 :: Int)




More information about the ghc-commits mailing list