From 05d9b5ae34f778989b0e3896021851d81e5c3a7d Mon Sep 17 00:00:00 2001
From: simonmar <unknown>
Date: Wed, 19 Jan 2000 17:08:02 +0000
Subject: [PATCH] [project @ 2000-01-19 17:08:02 by simonmar] - add some more
 test cases, now shows up the minInt bugs in Integer division.

---
 ghc/tests/numeric/should_run/arith003.hs | 73 ++++++++++++++++++++----
 1 file changed, 63 insertions(+), 10 deletions(-)

diff --git a/ghc/tests/numeric/should_run/arith003.hs b/ghc/tests/numeric/should_run/arith003.hs
index efbf2b929fb9..6102b6bd615d 100644
--- a/ghc/tests/numeric/should_run/arith003.hs
+++ b/ghc/tests/numeric/should_run/arith003.hs
@@ -1,11 +1,7 @@
--- !!! test arithmetic operations from "Prelude" (gcd, ldm, etc.)
+-- !!! test arithmetic operations from "Prelude" (gcd, lcm, etc.)
 --
 main
-  = let
-	minInt = minBound :: Int
-	maxInt = maxBound :: Int
-    in
-    putStr
+  = putStr
        (-- w/ Ints
 	show [
 	    minInt, maxInt,
@@ -21,7 +17,7 @@ main
 	    gcd i8m i0,
 	    gcd i0 i8m,
 	    gcd (4070297::Int) (2695911::Int), -- 52,861
-	    
+    
 	    lcm i8 i6,
 	    lcm i8m i6,
 	    lcm i8m i6m,
@@ -37,14 +33,31 @@ main
 	    ]
     	++ "\n"
 
+	++ show [
+	    quotRem i8 i6,
+	    quotRem i8m i6,
+	    quotRem i8m i6m,
+	    -- quotRem i8m i0,  -- no div by zero
+	    quotRem i0 i8m,
+	    quotRem (4070297::Int) (2695911::Int), -- 52,861
+
+	    divMod i8 i6,
+	    divMod i8m i6,
+	    divMod i8m i6m,
+	    -- divMod i8m i0,  -- no div by zero
+	    divMod i0 i8m,
+	    divMod (4070297::Int) (2695911::Int) -- 52,861
+            ]
+    	++ "\n"
+
         -- w/ Integers
 	++ show [
-	    toInteger minInt, toInteger maxInt,
+	    minIntI, maxIntI,
 
 	    subtract i8I i4I,
 	    subtract i8mI i4I,
-	    subtract (toInteger maxInt) i4I,
-	    subtract i0I (toInteger minInt),
+	    subtract maxIntI i4I,
+	    subtract i0I minIntI,
 
 	    gcd i8I i6I,
 	    gcd i8mI i6I,
@@ -52,6 +65,10 @@ main
 	    gcd i8mI i0I,
 	    gcd i0I i8mI,
 	    gcd (4070297::Integer) (2695911::Integer), -- 52,861
+	    gcd minIntI (-1),   -- out of Int range
+	    gcd minIntI (1),
+	    gcd (-1) minIntI,
+	    gcd (1)  minIntI,
 	    
 	    lcm i8I i6I,
 	    lcm i8mI i6I,
@@ -59,6 +76,10 @@ main
 	    lcm i8mI i0I,
 	    lcm i0I i8mI,
 	    lcm (4070297::Integer) (2695911::Integer), -- 207,585,147
+	    lcm minIntI (-1),   -- out of Int range
+	    lcm minIntI (1),
+	    lcm (-1) minIntI,
+	    lcm (1)  minIntI,
 
 	    i8I ^ i0I,
 	    i8mI ^ i4I,
@@ -66,6 +87,32 @@ main
 	    -- ToDo: more stuff
 	    ]
     	++ "\n"
+        
+	++ show [
+	    quotRem i8I i6I,
+	    quotRem i8mI i6I,
+	    quotRem i8mI i6mI,
+	    -- quotRem i8mI i0I,  -- no div by zero
+	    quotRem i0I i8mI,
+	    quotRem (4070297::Integer) (2695911::Integer), -- 52,861
+	    quotRem minIntI (-1),   -- out of Int range
+	    quotRem minIntI (1),
+	    quotRem (-1) minIntI,
+	    quotRem (1)  minIntI,
+
+	    divMod i8I i6I,
+	    divMod i8mI i6I,
+	    divMod i8mI i6mI,
+	    -- divMod i8mI i0I,  -- no div by zero
+	    divMod i0I i8mI,
+	    divMod (4070297::Integer) (2695911::Integer), -- 52,861
+	    divMod minIntI (-1),   -- out of Int range
+	    divMod minIntI (1),
+	    divMod (-1) minIntI,
+	    divMod (1)  minIntI
+	    ]
+
+    	++ "\n"
     	)
   where
     i0, i4, i4m, i6, i6m, i8, i8m :: Int
@@ -85,3 +132,9 @@ main
     i6mI = -6
     i8I = 8
     i8mI = -8
+
+minInt = minBound :: Int
+maxInt = maxBound :: Int
+
+minIntI = fromIntegral minInt :: Integer
+maxIntI = fromIntegral maxInt :: Integer
-- 
GitLab