X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Ftests%2Fnumeric%2Fshould_run%2Farith003.hs;fp=ghc%2Ftests%2Fnumeric%2Fshould_run%2Farith003.hs;h=0000000000000000000000000000000000000000;hb=16acb4976514ab4b03c79d6845e3f0e98a1a33cf;hp=ff7e83384c1f4000b0144726dcb168bab6d1ba5f;hpb=f2eadfd5dfb23cc611e2540f46180bca7d095f15;p=ghc-hetmet.git diff --git a/ghc/tests/numeric/should_run/arith003.hs b/ghc/tests/numeric/should_run/arith003.hs deleted file mode 100644 index ff7e833..0000000 --- a/ghc/tests/numeric/should_run/arith003.hs +++ /dev/null @@ -1,78 +0,0 @@ --- $Id: arith003.hs,v 1.5 2000/03/23 09:32:36 simonmar Exp $ --- --- !!! test Int/Integer arithmetic operations from the Prelude. --- - -main - = putStr - ( - showit (do_ops int_ops) ++ - showit (do_ops integer_ops) - ) - -showit :: Integral a => [(String, a, a, a)] -> String -showit stuff = concat - [ str ++ " " ++ show l ++ " " ++ show r ++ " = " ++ show result ++ "\n" - | (str, l, r, result) <- stuff - ] - -do_ops :: Integral a => [((a -> a -> a), String, [(a,a)])] - -> [(String, a, a, a)] -do_ops ops = [ (str, l, r, l `op` r) | (op,str,args) <- ops, (l,r) <- args ] - -small_operands, non_min_operands, operands, non_max_operands - :: Integral a => [a] -small_operands = [ 0, 1, -1, 2, -2 ] -operands = small_operands ++ [ fromIntegral minInt, fromIntegral maxInt ] -non_min_operands = small_operands ++ [ fromIntegral maxInt ] -non_max_operands = small_operands ++ [ fromIntegral minInt ] - -large_operands :: [ Integer ] -large_operands = operands ++ - [ fromIntegral minInt - 1, - fromIntegral maxInt + 1, - fromIntegral minInt * 2, - fromIntegral maxInt * 2, - fromIntegral minInt ^ 2, - fromIntegral maxInt ^ 2 - ] - -integer_ops :: [((Integer -> Integer -> Integer), String, [(Integer,Integer)])] -integer_ops = [ - ((+), "(+)", all_ok), - ((-), "(-)", all_ok), - (div, "div", large_non_zero_r), - (mod, "mod", large_non_zero_r), - (quot, "quot", large_non_zero_r), - (rem, "rem", large_non_zero_r), - (gcd, "gcd", either_non_zero), - (lcm, "lcm", either_non_zero) - ] - -int_ops :: [((Int -> Int -> Int), String, [(Int,Int)])] -int_ops = [ - ((+), "(+)", all_ok), - ((-), "(-)", all_ok), - ((^), "(^)", small_non_neg_r), - (div, "div", non_min_l_or_zero_r), - (mod, "mod", non_min_l_or_zero_r), - (quot, "quot", non_min_l_or_zero_r), - (rem, "rem", non_min_l_or_zero_r), - (gcd, "gcd", either_non_zero), - (lcm, "lcm", non_max_r_either_non_zero) - ] - -all_ok, non_zero_r, either_non_zero, non_min_l_or_zero_r, - non_max_r_either_non_zero, small_non_neg_r - :: Integral a => [(a,a)] - -all_ok = [ (l,r) | l <- operands, r <- operands ] -large_non_zero_r = [ (l,r) | l <- operands, r <- large_operands, r /= 0 ] -non_zero_r = [ (l,r) | l <- operands, r <- operands, r /= 0 ] -either_non_zero = [ (l,r) | l <- operands, r <- operands, l /= 0 || r /= 0 ] -small_non_neg_r = [ (l,r) | l <- operands, r <- small_operands, r >= 0 ] -non_min_l_or_zero_r = [ (l,r) | l <- non_min_operands, r <- operands, r /= 0 ] -non_max_r_either_non_zero = [ (l,r) | l <- operands, r <- non_max_operands, l /= 0 || r /= 0 ] - -minInt = minBound :: Int -maxInt = maxBound :: Int