1437b8799da8a75c39aa852681d7465fbefff844
[ghc.git] / testsuite / tests / numeric / should_run / arith016.hs
1 {-# LANGUAGE MagicHash #-}
2
3 module Main where
4
5 import GHC.Exts ( Float(F#),
6 eqFloat#, neFloat#, ltFloat#,
7 leFloat#, gtFloat#, geFloat#
8 )
9
10 fcmp_eq, fcmp_ne, fcmp_lt, fcmp_le, fcmp_gt, fcmp_ge :: (String, Float -> Float -> Bool)
11 fcmp_eq = ("==", \ (F# a) (F# b) -> a `eqFloat#` b)
12 fcmp_ne = ("/=", \ (F# a) (F# b) -> a `neFloat#` b)
13 fcmp_lt = ("< ", \ (F# a) (F# b) -> a `ltFloat#` b)
14 fcmp_le = ("<=", \ (F# a) (F# b) -> a `leFloat#` b)
15 fcmp_gt = ("> ", \ (F# a) (F# b) -> a `gtFloat#` b)
16 fcmp_ge = (">=", \ (F# a) (F# b) -> a `geFloat#` b)
17
18 float_fns = [fcmp_eq, fcmp_ne, fcmp_lt, fcmp_le, fcmp_gt, fcmp_ge]
19
20 float_vals :: [Float]
21 float_vals = [0.0, 1.0, read "NaN"]
22
23 float_text
24 = [show4 arg1 ++ " " ++ fn_name ++ " " ++ show4 arg2 ++ " = " ++ show (fn arg1 arg2)
25 | (fn_name, fn) <- float_fns,
26 arg1 <- float_vals,
27 arg2 <- float_vals
28 ]
29 where
30 show4 x = take 4 (show x ++ repeat ' ')
31
32 main
33 = putStrLn (unlines float_text)