diff options
author | simonmar <unknown> | 1999-11-26 16:29:44 +0000 |
---|---|---|
committer | simonmar <unknown> | 1999-11-26 16:29:44 +0000 |
commit | 7700dda03d273676b274bc148491a4e02a7c5ae0 (patch) | |
tree | 09de9743e3b9f9c7a4108660230969ce893947df /ghc/lib/misc/tests | |
parent | ef33ed94129ee17b577add392e04619ec1f53800 (diff) | |
download | haskell-7700dda03d273676b274bc148491a4e02a7c5ae0.tar.gz |
[project @ 1999-11-26 16:29:09 by simonmar]
GHC bits for new library organisation.
Diffstat (limited to 'ghc/lib/misc/tests')
-rw-r--r-- | ghc/lib/misc/tests/finite-maps/Main.hs | 77 | ||||
-rw-r--r-- | ghc/lib/misc/tests/finite-maps/Makefile | 5 | ||||
-rw-r--r-- | ghc/lib/misc/tests/finite-maps/ghclib001.stdin | 2 | ||||
-rw-r--r-- | ghc/lib/misc/tests/finite-maps/ghclib001.stdout | 11 |
4 files changed, 0 insertions, 95 deletions
diff --git a/ghc/lib/misc/tests/finite-maps/Main.hs b/ghc/lib/misc/tests/finite-maps/Main.hs deleted file mode 100644 index b5ceae4f31..0000000000 --- a/ghc/lib/misc/tests/finite-maps/Main.hs +++ /dev/null @@ -1,77 +0,0 @@ --- Test module for Finite Maps - -module Main where - -import IO -import FiniteMap -import Util - -main = hGetContents stdin >>= \ input -> - let (s1, rest1) = rd_int input - r1 = test1 s1 - - (s2, rest2) = rd_int rest1 - r2 = test2 s2 - in - putStr r1 >> - putStr r2 - -rd_int = \ i -> (head (reads i)) :: (Int,String) - - -------------------------------------------------------------- ---Test 1 creates two big maps with the same domain, mapping ---each domain elt to 1. - -test1 :: Int -- Size of maps - -> String - -test1 size - = "Test 1" ++ "\n" ++ - "N = " ++ show size ++ "\n" ++ - "Tot sum = " ++ --- show (fmToList fm1) ++ show (fmToList fm2) ++ show (fmToList sum_fm) ++ - show tot_sum ++ "\n" ++ - "Differences: " ++ diff ++ "\n" ++ - "Sum intersection:" ++ show sum_int ++ "\n\n" - where - fm1,fm2 :: FiniteMap Int Int - fm1 = listToFM [(i,1) | i <- [1..size-1]] - fm2 = listToFM [(i,1) | i <- [size,size-1..2]] - - -- Take their sum - sum_fm = plusFM_C (+) fm1 fm2 - tot_sum = sum (map get [1..size]) - get n = lookupWithDefaultFM sum_fm (error ("lookup" ++ show n)) n - -- Should be 1 + (size-2)*2 + 1 = 2*size - 2 - - - -- Take their difference - diff_fm1 = fm1 `minusFM` fm2 -- Should be a singleton - diff_fm2 = fm2 `minusFM` fm1 -- Should be a singleton - diff = show (fmToList diff_fm1) ++ "; " ++ show (fmToList diff_fm2) - - -- Take their intersection - int_fm = intersectFM_C (+) fm1 fm2 - sum_int = foldFM (\k n tot -> n+tot) 0 int_fm - - -test2 :: Int -- No of maps - -> String - -test2 size - = "Test 2" ++ "\n" ++ - "N = " ++ show size ++ "\n" ++ - "Sizes =" ++ show [sizeFM fm1,sizeFM fm2] ++ "\n" ++ - "Sums = " ++ show [sum1,sum2] ++ "\n\n" - where - fm1,fm2 :: FiniteMap Int Int - - fms1 = [unitFM i 1 | i <- [1..size]] - fm1 = foldr (plusFM_C (+)) emptyFM fms1 - - fms2 = [unitFM 1 i | i <- [1..size]] - fm2 = foldr (plusFM_C (+)) emptyFM fms2 - - sum1 = foldr (+) 0 (eltsFM fm1) - sum2 = foldr (+) 0 (eltsFM fm2) diff --git a/ghc/lib/misc/tests/finite-maps/Makefile b/ghc/lib/misc/tests/finite-maps/Makefile deleted file mode 100644 index 05055dd2b5..0000000000 --- a/ghc/lib/misc/tests/finite-maps/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -TOP = ../../.. -include $(TOP)/mk/boilerplate.mk -SRC_HC_OPTS += -syslib ghc -SRC_RUNTEST_OPTS += +RTS -H25m -RTS -include $(TOP)/mk/target.mk diff --git a/ghc/lib/misc/tests/finite-maps/ghclib001.stdin b/ghc/lib/misc/tests/finite-maps/ghclib001.stdin deleted file mode 100644 index 628db6e8a5..0000000000 --- a/ghc/lib/misc/tests/finite-maps/ghclib001.stdin +++ /dev/null @@ -1,2 +0,0 @@ -13133 -9798 diff --git a/ghc/lib/misc/tests/finite-maps/ghclib001.stdout b/ghc/lib/misc/tests/finite-maps/ghclib001.stdout deleted file mode 100644 index e989373e1e..0000000000 --- a/ghc/lib/misc/tests/finite-maps/ghclib001.stdout +++ /dev/null @@ -1,11 +0,0 @@ -Test 1 -N = 13133 -Tot sum = 26264 -Differences: [(1, 1)]; [(13133, 1)] -Sum intersection:26262 - -Test 2 -N = 9798 -Sizes =[9798, 1] -Sums = [9798, 48005301] - |