Ticket #2519: PicoTest.hs

File PicoTest.hs, 1.3 KB (added by Ansible, 6 years ago)

This is able to reproduce the bug, at least for me.

Line 
1module Main
2  where
3
4import IO
5import Random
6import System.Time
7
8{-
9picoCorrect :: TimeDiff -> TimeDiff
10picoCorrect td =
11 if (tdPicosec td) < 0
12  then
13   picoCorrect TimeDiff {
14            tdYear    = (tdYear td),
15            tdMonth   = (tdMonth td),
16            tdDay     = (tdDay td),
17            tdHour    = (tdHour td),
18            tdMin     = (tdMin td),
19            tdSec     = (tdSec td) - 1,
20            tdPicosec = (tdPicosec td) + 1000000000000
21            }
22  else
23   td
24-}
25
26picoCorrect td = td
27
28toSeconds :: ClockTime -> Double
29toSeconds (TOD x y) = 
30  fromInteger x +  (fromInteger y) / 1000000000000.0
31
32tdToSeconds :: TimeDiff -> Double
33tdToSeconds td = 
34 toSeconds (addToClockTime (picoCorrect td) (TOD 0 0))
35
36printClock (TOD x y) = do
37  putStr (show x)
38  putStr " seconds; "
39  putStr (show y)
40  putStr " picoseconds."
41
42main = do
43  hSetBuffering stdin LineBuffering
44  putStrLn "Welcome to the picotest.  Enter 'q' to quit."
45  doTest
46
47doTest = do
48  putStrLn "Hit enter for test: "
49  btime <- getClockTime
50  guess <- getLine
51  etime <- getClockTime
52  putStr "Clocktime1 "
53  printClock btime
54  putStrLn ""
55--  putStrLn (show btime)
56  putStr "Clocktime2 "
57  printClock etime
58  putStrLn ""
59--  putStrLn (show etime)
60  putStr "TimeDiff "
61  putStrLn (show (diffClockTimes etime btime))
62  putStr "converted to seconds: "
63  putStrLn (show (tdToSeconds (diffClockTimes etime btime)))
64  doTest
65
66