summaryrefslogtreecommitdiff
path: root/testsuite/tests/ghc-regress/numeric/should_run/3676.hs
blob: 242a9c5bb3b9960f64d0464e8b9be0e8c2024883 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
-- test conversion of funny numbers through Rational (#3676)

main = mapM_ putStrLn $ concat $
  [map (show.d2d) doubles1,
   map (show.d2f) doubles1,
   map (show.d2r) doubles1,
   map (show.f2d) floats1,
   map (show.f2f) floats1,
   map (show.f2r) floats1,
   map (show.d2d) doubles2,
   map (show.d2f) doubles2,
   map (show.d2r) doubles2,
   map (show.f2d) floats2,
   map (show.f2f) floats2,
   map (show.f2r) floats2
  ]

d2d = realToFrac :: Double -> Double
d2f = realToFrac :: Double -> Float
d2r = realToFrac :: Double -> Rational
f2d = realToFrac :: Float -> Double
f2f = realToFrac :: Float -> Float
f2r = realToFrac :: Float -> Rational

doubles1 = [0/0, 1/0, -1/0, 0/(-1)] :: [Double]
floats1  = [0/0, 1/0, -1/0, 0/(-1)] :: [Float]

doubles2 = names :: [Double]
floats2  = names :: [Float]

names :: Read a => [a]
names = map read ["NaN", "Infinity", "-Infinity", "-0"]