Commit bb74ed0d authored by simonm's avatar simonm
Browse files

[project @ 1998-01-07 19:07:03 by simonm]

Remove nofib/GHC_ONLY - all these tests are elsewhere in the tree now
(mostly in ghc/tests).
parent 34f22893
TOP = ..
include $(TOP)/mk/boilerplate.mk
# Leave the net* tests out of it for the moment, runstdtest is
# geared towards batch programs
#
# Also leave out stable* tests; the only one has a funny mixture of C
# and Haskell in it, so it needs attention.
SUBDIRS = $(wildcard frontend* arith* bugs cg* ghclib* io* obfuscated93 po*)
# io018 is not interesting here (it spins)
SUBDIRS := $(filter-out io018,$(SUBDIRS))
include $(TOP)/mk/target.mk
--!!! conversions: Double <=> Rational/Integer things
--
import Ratio
main = putStr (show r42 ++ "\n" ++
show nu42 ++ ", " ++
show de42 ++ "\n" ++
show nu42d ++ ", " ++
show de42d ++ "\n" ++
show s2 ++ ", " ++
show e2 ++ "\n" ++
show s ++ ", " ++
show e ++ "\n" )
where
d42 :: Double
r42 :: Rational
nu42, de42 :: Integer
nu42d, de42d :: Double
d42 = 42
r42 = toRational d42
nu42 = numerator r42
de42 = denominator r42
nu42d= fromInteger nu42
de42d= fromInteger de42
(s,e)= decodeFloat (nu42d / de42d )
(s2,e2) = decodeFloat d42
TOP = ../..
include $(TOP)/mk/boilerplate.mk
-include opts.mk
include $(TOP)/mk/target.mk
42 % 1
42, 1
42.0, 1.0
5910974510923776, -47
5910974510923776, -47
--!!! basic Rational operations
--
import Ratio
main
= putStr
(-- Ratio Ints
show [i0a, i0b, i0c, i2a, i2b, im2a, im2b, i_pi, i_misc]
++ "\n"
-- the Ints
++ show ((map numerator [i0a, i0b, i0c, i2a, i2b, im2a, im2b, i_pi, i_misc])
++(map denominator [i0a, i0b, i0c, i2a, i2b, im2a, im2b, i_pi, i_misc]))
++ "\n"
-- Booleans
-- ++ show []
-- ++ "\n"
-- Rationals (Ratio Integers)
++ show [r0a, r0b, r0c, r2a, r2b, rm2a, rm2b, r_pi, r_misc]
++ "\n"
-- the Integers
++ show ((map numerator [r0a, r0b, r0c, r2a, r2b, rm2a, rm2b, r_pi, r_misc])
++(map denominator [r0a, r0b, r0c, r2a, r2b, rm2a, rm2b, r_pi, r_misc]))
++ "\n"
-- Booleans
-- ++ show []
-- ++ "\n"
)
where
i0a, i0b, i0c, i2a, i2b, im2a, im2b, i_pi, i_misc :: Ratio Int
i0a = 0 % 1
i0b = -0 % 1
i0c = 0 % -1
i2a = 4 % 2
i2b = -4 % -2
im2a = -4 % 2
im2b = 4 % -2
i_pi = 22 % 7
i_misc = 2 % 10000
r0a, r0b, r0c, r2a, r2b, rm2a, rm2b, r_pi, r_misc :: Rational
r0a = 0 % 1
r0b = -0 % 1
r0c = 0 % -1
r2a = 4 % 2
r2b = -4 % -2
rm2a = -4 % 2
rm2b = 4 % -2
r_pi = 22 % 7
r_misc = 2 % 10000
TOP = ../..
include $(TOP)/mk/boilerplate.mk
-include opts.mk
include $(TOP)/mk/target.mk
[0 % 1, 0 % 1, 0 % 1, 2 % 1, 2 % 1, -2 % 1, -2 % 1, 22 % 7, 1 % 5000]
[0, 0, 0, 2, 2, -2, -2, 22, 1, 1, 1, 1, 1, 1, 1, 1, 7, 5000]
[0 % 1, 0 % 1, 0 % 1, 2 % 1, 2 % 1, -2 % 1, -2 % 1, 22 % 7, 1 % 5000]
[0, 0, 0, 2, 2, -2, -2, 22, 1, 1, 1, 1, 1, 1, 1, 1, 7, 5000]
--!!! test arithmetic operations from "Prelude" (gcd, ldm, etc.)
--
main
= let
minInt = minBound :: Int
maxInt = maxBound :: Int
in
putStr
(-- w/ Ints
show [
minInt, maxInt,
subtract i8 i4,
subtract i8m i4,
subtract maxInt i4,
subtract i0 minInt,
gcd i8 i6,
gcd i8m i6,
gcd i8m i6m,
gcd i8m i0,
gcd i0 i8m,
gcd (4070297::Int) (2695911::Int), -- 52,861
lcm i8 i6,
lcm i8m i6,
lcm i8m i6m,
lcm i8m i0,
lcm i0 i8m,
lcm (4070297::Int) (2695911::Int), -- 207,585,147
i8 ^ i0,
i8m ^ i4,
i4 ^ i6
-- ToDo: more stuff
]
++ "\n"
-- w/ Integers
++ show [
toInteger minInt, toInteger maxInt,
subtract i8I i4I,
subtract i8mI i4I,
subtract (toInteger maxInt) i4I,
subtract i0I (toInteger minInt),
gcd i8I i6I,
gcd i8mI i6I,
gcd i8mI i6mI,
gcd i8mI i0I,
gcd i0I i8mI,
gcd (4070297::Integer) (2695911::Integer), -- 52,861
lcm i8I i6I,
lcm i8mI i6I,
lcm i8mI i6mI,
lcm i8mI i0I,
lcm i0I i8mI,
lcm (4070297::Integer) (2695911::Integer), -- 207,585,147
i8I ^ i0I,
i8mI ^ i4I,
i4I ^ i6I
-- ToDo: more stuff
]
++ "\n"
)
where
i0, i4, i4m, i6, i6m, i8, i8m :: Int
i0 = 0
i4 = 4
i4m = -4
i6 = 6
i6m = -6
i8 = 8
i8m = -8
i0I, i4I, i4mI, i6I, i6mI, i8I, i8mI :: Integer
i0I = 0
i4I = 4
i4mI = -4
i6I = 6
i6mI = -6
i8I = 8
i8mI = -8
TOP = ../..
include $(TOP)/mk/boilerplate.mk
-include opts.mk
include $(TOP)/mk/target.mk
[-2147483647, 2147483647, -4, 12, -2147483643, -2147483647, 2, 2, 2, 8, 8, 52861, 24, 24, 24, 0, 0, 207585147, 1, 4096, 4096]
[-2147483647, 2147483647, -4, 12, -2147483643, -2147483647, 2, 2, 2, 8, 8, 52861, 24, 24, 24, 0, 0, 207585147, 1, 4096, 4096]
--!!! test quot/rem/div/mod functions on Ints and Integers
--
main
= putStr
(-- w/ Ints and Integers
show (unzipWith div ints_list)
++ "\n"
++ show (unzipWith div integers_list)
++ "\n"
++ show (unzipWith rem ints_list)
++ "\n"
++ show (unzipWith rem integers_list)
++ "\n"
++ show (unzipWith quot ints_list)
++ "\n"
++ show (unzipWith quot integers_list)
++ "\n"
++ show (unzipWith mod ints_list)
++ "\n"
++ show (unzipWith mod integers_list)
++ "\n"
++ show (unzipWith law1 ints_list)
++ "\n"
++ show (unzipWith law1 integers_list)
++ "\n"
++ show (unzipWith law2 ints_list)
++ "\n"
++ show (unzipWith law2 integers_list)
++ "\n"
)
where
ints_list :: [(Int, Int)]
integers_list :: [(Integer, Integer)]
ints_list = [
(0, 4),
(0, -8),
(7, 3),
(13, 4),
(13, -4),
(-13, 4),
(-13, -4),
(12345678, 10000),
(12345678, -10000),
(-12345678, 10000),
(-12345678, -10000),
(123456,10000),
(1234567,20000),
(12345678,-10000),
(123456789,10000),
(1234567890,-10000),
(-12345,10000),
(-123456789,-10000)
]
integers_list = [
(0, 4),
(0, -8),
(7, 3),
(13, 4),
(13, -4),
(-13, 4),
(-13, -4),
(12345678, 10000),
(12345678, -10000),
(-12345678, 10000),
(-12345678, -10000),
(123456,10000),
(1234567,20000),
(12345678,-10000),
(123456789,10000),
(1234567890,-10000),
(-12345,10000),
(-123456789,-10000),
(12345678900,500000000),
(1234000000000000000000005678900,5001111111111111000000)
]
unzipWith :: (a -> b -> c) -> [(a,b)] -> [c]
unzipWith f [] = []
unzipWith f ((x,y):zs) = f x y : unzipWith f zs
law1, law2 :: Integral a => a -> a -> Bool
law1 x y = (x `quot` y)*y + (x `rem` y) == x
law2 x y = (x `div` y)*y + (x `mod` y) == x
TOP = ../..
include $(TOP)/mk/boilerplate.mk
-include opts.mk
include $(TOP)/mk/target.mk
[0, 0, 2, 3, -4, -4, 3, 1234, -1235, -1235, 1234, 12, 61, -1235, 12345, -123457, -2, 12345]
[0, 0, 2, 3, -4, -4, 3, 1234, -1235, -1235, 1234, 12, 61, -1235, 12345, -123457, -2, 12345, 24, 246745167]
[0, 0, 1, 1, 1, -1, -1, 5678, 5678, -5678, -5678, 3456, 14567, 5678, 6789, 7890, -2345, -6789]
[0, 0, 1, 1, 1, -1, -1, 5678, 5678, -5678, -5678, 3456, 14567, 5678, 6789, 7890, -2345, -6789, 345678900, 3703333360749468678900]
[0, 0, 2, 3, -3, -3, 3, 1234, -1234, -1234, 1234, 12, 61, -1234, 12345, -123456, -1, 12345]
[0, 0, 2, 3, -3, -3, 3, 1234, -1234, -1234, 1234, 12, 61, -1234, 12345, -123456, -1, 12345, 24, 246745167]
[0, 0, 1, 1, -3, 3, -1, 5678, -4322, 4322, -5678, 3456, 14567, -4322, 6789, -2110, 7655, -6789]
[0, 0, 1, 1, -3, 3, -1, 5678, -4322, 4322, -5678, 3456, 14567, -4322, 6789, -2110, 7655, -6789, 345678900, 3703333360749468678900]
[True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True]
[True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True]
[True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True]
[True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True]
--!!! test RealFrac ops (ceiling/floor/etc.) on Floats/Doubles
--
main
= putStr
(-- {Float,Double} inputs, {Int,Integer} outputs
show ((map ceiling float_list) :: [Int])
++ "\n"
++ show ((map ceiling float_list) :: [Integer])
++ "\n"
++ show ((map ceiling double_list) :: [Int])
++ "\n"
++ show ((map ceiling double_list) :: [Integer])
++ "\n"
++ show ((map floor float_list) :: [Int])
++ "\n"
++ show ((map floor float_list) :: [Integer])
++ "\n"
++ show ((map floor double_list) :: [Int])
++ "\n"
++ show ((map floor double_list) :: [Integer])
++ "\n"
++ show ((map truncate float_list) :: [Int])
++ "\n"
++ show ((map truncate float_list) :: [Integer])
++ "\n"
++ show ((map truncate double_list) :: [Int])
++ "\n"
++ show ((map truncate double_list) :: [Integer])
++ "\n"
++ show ((map round float_list) :: [Int])
++ "\n"
++ show ((map round float_list) :: [Integer])
++ "\n"
++ show ((map round double_list) :: [Int])
++ "\n"
++ show ((map round double_list) :: [Integer])
++ "\n"
++ show ((map properFraction float_list) :: [(Int,Float)])
++ "\n"
++ show ((map properFraction float_list) :: [(Integer,Float)])
++ "\n"
++ show ((map properFraction double_list) :: [(Int,Double)])
++ "\n"
++ show ((map properFraction double_list) :: [(Integer,Double)])
++ "\n"
)
where
float_list :: [Float]
float_list = [
0.0, -0.0, 1.1, 2.8, 3.5, 4.5, -1.0000000001, -2.9999995,
-3.50000000001, -4.49999999999, 1000012.0, 123.456, 100.25,
102.5, 0.0012, -0.00000012, 1.7e4, -1.7e-4, 0.15e-6, pi
]
double_list :: [Double]
double_list = [
0.0, -0.0, 1.1, 2.8, 3.5, 4.5, -1.0000000001, -2.9999995,
-3.50000000001, -4.49999999999, 1000012.0, 123.456, 100.25,
102.5, 0.0012, -0.00000012, 1.7e4, -1.7e-4, 0.15e-6, pi
]
TOP = ../..
include $(TOP)/mk/boilerplate.mk
-include opts.mk
include $(TOP)/mk/target.mk
[0, 0, 2, 3, 4, 5, -1, -2, -3, -4, 1000012, 124, 101, 103, 1, 0, 17000, 0, 1, 4]
[0, 0, 2, 3, 4, 5, -1, -2, -3, -4, 1000012, 124, 101, 103, 1, 0, 17000, 0, 1, 4]
[0, 0, 2, 3, 4, 5, -1, -2, -3, -4, 1000012, 124, 101, 103, 1, 0, 17000, 0, 1, 4]
[0, 0, 2, 3, 4, 5, -1, -2, -3, -4, 1000012, 124, 101, 103, 1, 0, 17000, 0, 1, 4]
[0, 0, 1, 2, 3, 4, -1, -3, -4, -5, 1000012, 123, 100, 102, 0, -1, 17000, -1, 0, 3]
[0, 0, 1, 2, 3, 4, -1, -3, -4, -5, 1000012, 123, 100, 102, 0, -1, 17000, -1, 0, 3]
[0, 0, 1, 2, 3, 4, -2, -3, -4, -5, 1000012, 123, 100, 102, 0, -1, 17000, -1, 0, 3]
[0, 0, 1, 2, 3, 4, -2, -3, -4, -5, 1000012, 123, 100, 102, 0, -1, 17000, -1, 0, 3]
[0, 0, 1, 2, 3, 4, -1, -2, -3, -4, 1000012, 123, 100, 102, 0, 0, 17000, 0, 0, 3]
[0, 0, 1, 2, 3, 4, -1, -2, -3, -4, 1000012, 123, 100, 102, 0, 0, 17000, 0, 0, 3]
[0, 0, 1, 2, 3, 4, -1, -2, -3, -4, 1000012, 123, 100, 102, 0, 0, 17000, 0, 0, 3]
[0, 0, 1, 2, 3, 4, -1, -2, -3, -4, 1000012, 123, 100, 102, 0, 0, 17000, 0, 0, 3]
[0, 0, 1, 3, 4, 4, -1, -3, -4, -4, 1000012, 123, 100, 102, 0, 0, 17000, 0, 0, 3]
[0, 0, 1, 3, 4, 4, -1, -3, -4, -4, 1000012, 123, 100, 102, 0, 0, 17000, 0, 0, 3]
[0, 0, 1, 3, 4, 4, -1, -3, -4, -4, 1000012, 123, 100, 102, 0, 0, 17000, 0, 0, 3]
[0, 0, 1, 3, 4, 4, -1, -3, -4, -4, 1000012, 123, 100, 102, 0, 0, 17000, 0, 0, 3]
[(0, 0.0), (0, 0.0), (1, 0.100000024), (2, 0.79999995), (3, 0.5), (4, 0.5), (-1, 0.0), (-2, -0.9999995), (-3, -0.5), (-4, -0.5), (1000012, 0.0), (123, 0.45600128), (100, 0.25), (102, 0.5), (0, 1.2e-3), (0, -1.2e-7), (17000, 0.0), (0, -1.7e-4), (0, 1.5e-7), (3, 0.14159274)]
[(0, 0.0), (0, 0.0), (1, 0.100000024), (2, 0.79999995), (3, 0.5), (4, 0.5), (-1, 0.0), (-2, -0.9999995), (-3, -0.5), (-4, -0.5), (1000012, 0.0), (123, 0.45600128), (100, 0.25), (102, 0.5), (0, 1.2e-3), (0, -1.2e-7), (17000, 0.0), (0, -1.7e-4), (0, 1.5e-7), (3, 0.14159274)]
[(0, 0.0), (0, 0.0), (1, 0.10000000000000009), (2, 0.7999999999999998), (3, 0.5), (4, 0.5), (-1, -1.000000082740371e-10), (-2, -0.9999994999999999), (-3, -0.50000000001), (-4, -0.49999999999), (1000012, 0.0), (123, 0.45600000000000307), (100, 0.25), (102, 0.5), (0, 1.2e-3), (0, -1.2e-7), (17000, 0.0), (0, -1.7e-4), (0, 1.5e-7), (3, 0.14159265358979312)]
[(0, 0.0), (0, 0.0), (1, 0.10000000000000009), (2, 0.7999999999999998), (3, 0.5), (4, 0.5), (-1, -1.000000082740371e-10), (-2, -0.9999994999999999), (-3, -0.50000000001), (-4, -0.49999999999), (1000012, 0.0), (123, 0.45600000000000307), (100, 0.25), (102, 0.5), (0, 1.2e-3), (0, -1.2e-7), (17000, 0.0), (0, -1.7e-4), (0, 1.5e-7), (3, 0.14159265358979312)]
--!!! printing Floats; was a bug in hbc (reported by andy)
--
main = print ((fromInt 42) :: Float)
TOP = ../..
include $(TOP)/mk/boilerplate.mk
-include opts.mk
include $(TOP)/mk/target.mk
--!!! test simple Integer things
--
main
= putStr (shows integer_list "\n")
where
int_list :: [Int]
integer_list :: [Integer]
int_list = (map fromInteger integer_list)
integer_list = (map (* 2)
[1,3,5,7,9,
11111111111111111111111111111,
2222222222222222222222222222222222222,
3333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333,
-11111111111111111111111111111,
-2222222222222222222222222222222222222,
-3333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333
])
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment