[project @ 1998-09-07 12:08:10 by sof]
authorsof <unknown>
Mon, 7 Sep 1998 12:08:22 +0000 (12:08 +0000)
committersof <unknown>
Mon, 7 Sep 1998 12:08:22 +0000 (12:08 +0000)
Some Numeric lib tests

14 files changed:
ghc/tests/numeric/should_run/num001.hs [new file with mode: 0644]
ghc/tests/numeric/should_run/num001.stdout [new file with mode: 0644]
ghc/tests/numeric/should_run/num002.hs [new file with mode: 0644]
ghc/tests/numeric/should_run/num002.stdout [new file with mode: 0644]
ghc/tests/numeric/should_run/num003.hs [new file with mode: 0644]
ghc/tests/numeric/should_run/num003.stdout [new file with mode: 0644]
ghc/tests/numeric/should_run/num004.hs [new file with mode: 0644]
ghc/tests/numeric/should_run/num004.stdout [new file with mode: 0644]
ghc/tests/numeric/should_run/num005.hs [new file with mode: 0644]
ghc/tests/numeric/should_run/num006.hs [new file with mode: 0644]
ghc/tests/numeric/should_run/num006.stdout [new file with mode: 0644]
ghc/tests/numeric/should_run/num007.hs [new file with mode: 0644]
ghc/tests/numeric/should_run/num007.stdout [new file with mode: 0644]
ghc/tests/numeric/should_run/num008.hs [new file with mode: 0644]

diff --git a/ghc/tests/numeric/should_run/num001.hs b/ghc/tests/numeric/should_run/num001.hs
new file mode 100644 (file)
index 0000000..a27e0d2
--- /dev/null
@@ -0,0 +1,5 @@
+module Main(main) where
+
+import Numeric
+
+main = print ((fromRat (132874 % 23849))::Double)
diff --git a/ghc/tests/numeric/should_run/num001.stdout b/ghc/tests/numeric/should_run/num001.stdout
new file mode 100644 (file)
index 0000000..6d2f0c7
--- /dev/null
@@ -0,0 +1 @@
+5.571470501907837
diff --git a/ghc/tests/numeric/should_run/num002.hs b/ghc/tests/numeric/should_run/num002.hs
new file mode 100644 (file)
index 0000000..b0de2bf
--- /dev/null
@@ -0,0 +1,17 @@
+-- Testing showInt, lightly.
+
+module Main(main) where
+
+import Numeric
+
+main = 
+  do
+   putStrLn (showInt (343023920121::Integer) [])
+   putStrLn (showInt (3430239::Int) [])
+   putStrLn (showInt (1212 :: Int) [])
+   putStrLn (showInt (591125662431 `div` (517::Int)) [])
+   -- showInt just works over naturals, wrap it up inside
+   -- a use of Numeric.showSigned to show negative nums.
+   putStrLn (showSigned (showInt) 0 (-111::Int) [])
+   putStrLn (showInt (232189458241::Integer) [])
+
diff --git a/ghc/tests/numeric/should_run/num002.stdout b/ghc/tests/numeric/should_run/num002.stdout
new file mode 100644 (file)
index 0000000..3b8e1e8
--- /dev/null
@@ -0,0 +1,6 @@
+343023920121
+3430239
+1212
+1097986
+-111
+232189458241
diff --git a/ghc/tests/numeric/should_run/num003.hs b/ghc/tests/numeric/should_run/num003.hs
new file mode 100644 (file)
index 0000000..0b8ea6b
--- /dev/null
@@ -0,0 +1,20 @@
+-- Testing readInt, lightly.
+--
+module Main(main) where
+
+import Numeric
+import Char
+
+main = 
+  let 
+   rd :: ReadS Integer 
+   rd = readInt 10 (isDigit) (digitToInt)
+  in
+  do
+   print (rd (show (343023920121::Integer)))
+   print (rd (show (3430239::Int)))
+   print (rd (show (1212 :: Int)))
+   print (rd (show (591125662431 `div` (517::Int))))
+   print (rd (show (-111::Int)))
+   print (rd (show (232189458241::Integer)))
+
diff --git a/ghc/tests/numeric/should_run/num003.stdout b/ghc/tests/numeric/should_run/num003.stdout
new file mode 100644 (file)
index 0000000..007cd36
--- /dev/null
@@ -0,0 +1,6 @@
+[(343023920121, "")]
+[(3430239, "")]
+[(1212, "")]
+[(1097986, "")]
+[]
+[(232189458241, "")]
diff --git a/ghc/tests/numeric/should_run/num004.hs b/ghc/tests/numeric/should_run/num004.hs
new file mode 100644 (file)
index 0000000..7822565
--- /dev/null
@@ -0,0 +1,20 @@
+-- Exercising Numeric.readSigned a bit
+--
+module Main(main) where
+
+import Numeric
+import Char
+
+main = 
+  let 
+   rd :: ReadS Integer 
+   rd = readSigned (readInt 10 (isDigit) (digitToInt))
+  in
+  do
+   print (rd (show (343023920121::Integer)))
+   print (rd (show (3430239::Int)))
+   print (rd (show (-0 :: Int)))
+   print (rd (show (591125662431 `div` (517::Int))))
+   print (rd (show (-111::Int)))
+   print (rd (show (232189458241::Integer)))
+
diff --git a/ghc/tests/numeric/should_run/num004.stdout b/ghc/tests/numeric/should_run/num004.stdout
new file mode 100644 (file)
index 0000000..e6959bf
--- /dev/null
@@ -0,0 +1,6 @@
+[(343023920121, "")]
+[(3430239, "")]
+[(0, "")]
+[(1097986, "")]
+[(-111, "")]
+[(232189458241, "")]
diff --git a/ghc/tests/numeric/should_run/num005.hs b/ghc/tests/numeric/should_run/num005.hs
new file mode 100644 (file)
index 0000000..ef647a6
--- /dev/null
@@ -0,0 +1,23 @@
+-- Exercising Numeric.readSigned a bit
+--
+module Main(main) where
+
+import Numeric
+
+main = 
+  let 
+   ls = ["3489348394032498320438240938403","0","-1","1","34323","2L","012","0x23","3243ab"]
+   present str f ls =
+    sequence (map (\ v -> putStr ('\n':str ++ 
+                                  ' ': v   ++ 
+                                 " = "    ++ 
+                                 (show (f v)))) ls)
+  in
+  do
+   present "(readDec::ReadS Integer)" (readDec::ReadS Integer) ls
+   present "(readDec::ReadS Int)"     (readDec::ReadS Int) ls
+   present "(readOct::ReadS Integer)" (readOct::ReadS Integer) ls
+   present "(readOct::ReadS Int)"     (readOct::ReadS Int) ls
+   present "(readHex::ReadS Integer)" (readHex::ReadS Integer) ls
+   present "(readHex::ReadS Int)"     (readHex::ReadS Int) ls
+   putStrLn ""
diff --git a/ghc/tests/numeric/should_run/num006.hs b/ghc/tests/numeric/should_run/num006.hs
new file mode 100644 (file)
index 0000000..0d848fd
--- /dev/null
@@ -0,0 +1,29 @@
+-- Exercising the showing of positive numbers at various bases.
+--
+module Main(main) where
+
+import Numeric
+import Char
+import NumExts
+
+--showDec :: Integral a => a -> ShowS
+showDec = showInt
+
+{-
+--showBinary :: Integral a => a -> ShowS
+showBinary n r = 
+ showString "0b" $
+ showIntAtBase 2 (toChr) n r
+ where toChr d = chr (ord '0' + fromIntegral d)
+-}
+
+main = 
+ do
+  print (map (\ x -> showOct x []) [1..32])
+  print (map (\ x -> showDec x []) [1..32])
+  print (map (\ x -> showHex x []) [1..32])
+--  print (map (\ x -> showBinary x []) [1..32])
+  putStrLn (showOct (241324784::Int) [])
+  putStrLn (showDec (241324784::Int) [])
+  putStrLn (showHex (241324784::Int) [])
+---  putStrLn (showBinary (241324784::Int) [])
diff --git a/ghc/tests/numeric/should_run/num006.stdout b/ghc/tests/numeric/should_run/num006.stdout
new file mode 100644 (file)
index 0000000..2645af1
--- /dev/null
@@ -0,0 +1,8 @@
+["0o1", "0o2", "0o3", "0o4", "0o5", "0o6", "0o7", "0o10", "0o11", "0o12", "0o13", "0o14", "0o15", "0o16", "0o17", "0o20", "0o21", "0o22", "0o23", "0o24", "0o25", "0o26", "0o27", "0o30", "0o31", "0o32", "0o33", "0o34", "0o35", "0o36", "0o37", "0o40"]
+["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"]
+["0x1", "0x2", "0x3", "0x4", "0x5", "0x6", "0x7", "0x8", "0x9", "0xa", "0xb", "0xc", "0xd", "0xe", "0xf", "0x10", "0x11", "0x12", "0x13", "0x14", "0x15", "0x16", "0x17", "0x18", "0x19", "0x1a", "0x1b", "0x1c", "0x1d", "0x1e", "0x1f", "0x20"]
+["0b1", "0b10", "0b11", "0b100", "0b101", "0b110", "0b111", "0b1000", "0b1001", "0b1010", "0b1011", "0b1100", "0b1101", "0b1110", "0b1111", "0b10000", "0b10001", "0b10010", "0b10011", "0b10100", "0b10101", "0b10110", "0b10111", "0b11000", "0b11001", "0b11010", "0b11011", "0b11100", "0b11101", "0b11110", "0b11111", "0b100000"]
+0o1630451360
+241324784
+0xe6252f0
+0b1110011000100101001011110000
diff --git a/ghc/tests/numeric/should_run/num007.hs b/ghc/tests/numeric/should_run/num007.hs
new file mode 100644 (file)
index 0000000..1c40ecf
--- /dev/null
@@ -0,0 +1,17 @@
+-- Exercising the reading of positive numbers at various bases.
+--
+module Main(main) where
+
+import Numeric
+
+main = 
+ do
+  putStrLn (show (readOct "00000111"))
+  putStrLn (show (readDec "00000111"))
+  putStrLn (show (readHex "00000111"))
+  putStrLn (show (readOct "-24"))
+  putStrLn (show (readDec "-24"))
+  putStrLn (show (readHex "-24"))
+  putStrLn (show ((readOct ::ReadS Integer) "3248784372843778438743"))
+  putStrLn (show ((readDec ::ReadS Integer) "3248784372843778438743"))
+  putStrLn (show ((readHex ::ReadS Integer) "3248784372843778438743"))
diff --git a/ghc/tests/numeric/should_run/num007.stdout b/ghc/tests/numeric/should_run/num007.stdout
new file mode 100644 (file)
index 0000000..70609a6
--- /dev/null
@@ -0,0 +1,9 @@
+"[(73, \"\")]"
+"[(111, \"\")]"
+"[(273, \"\")]"
+"[]"
+"[]"
+"[]"
+"[(212, \"8784372843778438743\")]"
+"[(3248784372843778438743, \"\")]"
+"[(60788519836879239998834499, \"\")]"
diff --git a/ghc/tests/numeric/should_run/num008.hs b/ghc/tests/numeric/should_run/num008.hs
new file mode 100644 (file)
index 0000000..d9e8c47
--- /dev/null
@@ -0,0 +1,21 @@
+-- showing floats
+--
+module Main(main) where
+
+import Numeric
+
+main = 
+ do
+  putStrLn (showEFloat (Just 7) (1.82173691287639817263897126389712638972163e-300::Double) [])
+  putStrLn (showFFloat (Just 7) (1.82173691287639817263897126389712638972163::Double) [])
+  putStrLn (showGFloat (Just 7) (1.82173691287639817263897126389712638972163e-300::Double) [])
+  putStrLn (showEFloat (Just 7) (1.82173691287639817263897126389712638972163e-300::Float) [])
+  putStrLn (showEFloat (Just 10) (0.0::Double) [])
+  putStrLn (showEFloat (Just 0) (2.3::Double) [])
+  putStrLn (showEFloat Nothing (0.0::Double) [])
+  putStrLn (showEFloat Nothing (3::Float) [])
+  putStrLn (showEFloat Nothing (0.5::Float) [])
+  putStrLn (show (floatToDigits 10 (0.0::Double)))
+  putStrLn (showFFloat (Just 7) (1.82173691287639817263897126389712638972163e-300::Float) [])
+  putStrLn (showGFloat (Just 7) (1.82173691287639817263897126389712638972163e-300::Float) [])
+