[Pkg-haskell-commits] [SCM] haskell-testpack branch, master, updated. debian/1.0.2-1-4-gb0d6b36
John Goerzen
jgoerzen at complete.org
Fri Apr 23 14:45:00 UTC 2010
The following commit has been merged in the master branch:
commit 850ee199c61f0ff738555a56ddafe0cbeccc518b
Author: John Goerzen <jgoerzen at complete.org>
Date: Thu Oct 21 09:45:38 2004 +0100
Added flipAL, flipFM and appropriate tests
Keywords:
(jgoerzen at complete.org--projects/missingh--head--1.0--patch-89)
diff --git a/ChangeLog b/ChangeLog
index 5b3cb45..6e03e8d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,21 @@
# arch-tag: automatic-ChangeLog--jgoerzen at complete.org--projects/missingh--head--1.0
#
+2004-10-21 03:45:38 GMT John Goerzen <jgoerzen at complete.org> patch-89
+
+ Summary:
+ Added flipAL, flipFM and appropriate tests
+ Revision:
+ missingh--head--1.0--patch-89
+
+
+ new files:
+ libsrc/MissingH/FiniteMap.hs testsrc/FiniteMaptest.hs
+
+ modified files:
+ ChangeLog testsrc/Listtest.hs testsrc/Tests.hs
+
+
2004-10-21 03:32:26 GMT John Goerzen <jgoerzen at complete.org> patch-88
Summary:
diff --git a/libsrc/MissingH/Network.hs b/libsrc/MissingH/FiniteMap.hs
similarity index 71%
copy from libsrc/MissingH/Network.hs
copy to libsrc/MissingH/FiniteMap.hs
index c278b1a..7867ce2 100644
--- a/libsrc/MissingH/Network.hs
+++ b/libsrc/MissingH/FiniteMap.hs
@@ -1,4 +1,4 @@
-{- arch-tag: Network utilities main file
+{- arch-tag: FiniteMap utilities main file
Copyright (C) 2004 John Goerzen <jgoerzen at complete.org>
This program is free software; you can redistribute it and/or modify
@@ -17,22 +17,28 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-}
{- |
- Module : MissingH.Network
+ Module : MissingH.FiniteMap
Copyright : Copyright (C) 2004 John Goerzen
License : GNU GPL, version 2 or above
Maintainer : John Goerzen,
Maintainer : jgoerzen at complete.org
Stability : provisional
- Portability: systems with networking
+ Portability: portable
-This module provides various helpful utilities for dealing with networking
+This module provides various helpful utilities for dealing with FiniteMaps.
Written by John Goerzen, jgoerzen\@complete.org
-}
-module MissingH.Network(
- )
+module MissingH.FiniteMap (flipFM)
where
--- nothing yet
\ No newline at end of file
+import Data.FiniteMap
+import MissingH.List(flipAL)
+
+{- | Flips a finite map. See 'MissingH.List.flipAL' for more on the similar
+function for lists. -}
+
+flipFM :: (Ord key, Ord val) => FiniteMap key val -> FiniteMap val [key]
+flipFM = listToFM . flipAL . fmToList
diff --git a/testsrc/Tests.hs b/testsrc/FiniteMaptest.hs
similarity index 54%
copy from testsrc/Tests.hs
copy to testsrc/FiniteMaptest.hs
index 65449c8..6b6e19b 100644
--- a/testsrc/Tests.hs
+++ b/testsrc/FiniteMaptest.hs
@@ -1,4 +1,4 @@
-{- arch-tag: Tests main file
+{- arch-tag: FiniteMap tests main file
Copyright (C) 2004 John Goerzen <jgoerzen at complete.org>
This program is free software; you can redistribute it and/or modify
@@ -16,16 +16,24 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-}
-module Tests(tests) where
+module FiniteMaptest(tests) where
import HUnit
-import qualified Listtest
-import qualified Strtest
-import qualified IOtest
-
-test1 = TestCase ("x" @=? "x")
-
-tests = TestList [TestLabel "test1" test1,
- TestLabel "List" Listtest.tests,
- TestLabel "Str" Strtest.tests]
-
-
+import MissingH.FiniteMap
+import Data.FiniteMap
+
+instance (Show a, Show b) => Show (FiniteMap a b) where
+ show fm = show (fmToList fm)
+
+test_flipFM =
+ let f inp exp = (listToFM exp) @=? flipFM (listToFM inp) in
+ do
+ f ([]::[(Int,Int)]) ([]::[(Int,[Int])])
+ f [("a", "b")] [("b", ["a"])]
+ f [("a", "b"),
+ ("c", "b"),
+ ("d", "e"),
+ ("b", "b")] [("b", ["c", "b", "a"]),
+ ("e", ["d"])]
+
+tests = TestList [TestLabel "flipFM" (TestCase test_flipFM)
+ ]
\ No newline at end of file
diff --git a/testsrc/Listtest.hs b/testsrc/Listtest.hs
index 35a50b1..abe1a5c 100644
--- a/testsrc/Listtest.hs
+++ b/testsrc/Listtest.hs
@@ -74,7 +74,7 @@ test_flipAL =
f [("a", "b"),
("c", "b"),
("d", "e"),
- ("b", "b")] [("b", ["a", "c", "d"]),
+ ("b", "b")] [("b", ["b", "c", "a"]),
("e", ["d"])]
test_trunc =
@@ -111,6 +111,7 @@ tests = TestList [TestLabel "delFromAL" (TestCase test_delFromAL),
TestLabel "join" (TestCase test_join),
TestLabel "genericJoin" (TestCase test_genericJoin),
TestLabel "trunc" (TestCase test_trunc),
+ TestLabel "flipAL" (TestCase test_flipAL),
TestLabel "contains" (TestCase test_contains)]
diff --git a/testsrc/Tests.hs b/testsrc/Tests.hs
index 65449c8..76907c6 100644
--- a/testsrc/Tests.hs
+++ b/testsrc/Tests.hs
@@ -19,6 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
module Tests(tests) where
import HUnit
import qualified Listtest
+import qualified FiniteMaptest
import qualified Strtest
import qualified IOtest
@@ -26,6 +27,7 @@ test1 = TestCase ("x" @=? "x")
tests = TestList [TestLabel "test1" test1,
TestLabel "List" Listtest.tests,
- TestLabel "Str" Strtest.tests]
+ TestLabel "Str" Strtest.tests,
+ TestLabel "FiniteMap" FiniteMaptest.tests]
--
haskell-testpack
More information about the Pkg-haskell-commits
mailing list