a219b5575e5b8c364e2a2654a7d2a278b948ce96
[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 isTrue#
9 )
10
11 fcmp_eq, fcmp_ne, fcmp_lt, fcmp_le, fcmp_gt, fcmp_ge :: (String, Float -> Float -> Bool)
12 fcmp_eq = ("==", \ (F# a) (F# b) -> isTrue# (a `eqFloat#` b))
13 fcmp_ne = ("/=", \ (F# a) (F# b) -> isTrue# (a `neFloat#` b))
14 fcmp_lt = ("< ", \ (F# a) (F# b) -> isTrue# (a `ltFloat#` b))
15 fcmp_le = ("<=", \ (F# a) (F# b) -> isTrue# (a `leFloat#` b))
16 fcmp_gt = ("> ", \ (F# a) (F# b) -> isTrue# (a `gtFloat#` b))
17 fcmp_ge = (">=", \ (F# a) (F# b) -> isTrue# (a `geFloat#` b))
18
19 float_fns = [fcmp_eq, fcmp_ne, fcmp_lt, fcmp_le, fcmp_gt, fcmp_ge]
20
21 float_vals :: [Float]
22 float_vals = [0.0, 1.0, read "NaN"]
23
24 float_text
25 = [show4 arg1 ++ " " ++ fn_name ++ " " ++ show4 arg2 ++ " = " ++ show (fn arg1 arg2)
26 | (fn_name, fn) <- float_fns,
27 arg1 <- float_vals,
28 arg2 <- float_vals
29 ]
30 where
31 show4 x = take 4 (show x ++ repeat ' ')
32
33 main
34 = putStrLn (unlines float_text)