[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:20 UTC 2010
The following commit has been merged in the master branch:
commit 66b4775e0a8831576f82f10b0d032af6e22a7114
Author: John Goerzen <jgoerzen at complete.org>
Date: Sat Oct 23 00:44:01 2004 +0100
Fixed tests, moved trunc to take
Keywords:
(jgoerzen at complete.org--projects/missingh--head--1.0--patch-99)
diff --git a/ChangeLog b/ChangeLog
index 9adf26b..144812c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,19 @@
# arch-tag: automatic-ChangeLog--jgoerzen at complete.org--projects/missingh--head--1.0
#
+2004-10-22 18:44:01 GMT John Goerzen <jgoerzen at complete.org> patch-99
+
+ Summary:
+ Fixed tests, moved trunc to take
+ Revision:
+ missingh--head--1.0--patch-99
+
+
+ modified files:
+ ChangeLog libsrc/MissingH/List.hs
+ libsrc/MissingH/Network/FTP/Parser.hs testsrc/Testutil.hs
+
+
2004-10-22 18:10:09 GMT John Goerzen <jgoerzen at complete.org> patch-98
Summary:
diff --git a/libsrc/MissingH/List.hs b/libsrc/MissingH/List.hs
index a4faf4f..4d2fcec 100644
--- a/libsrc/MissingH/List.hs
+++ b/libsrc/MissingH/List.hs
@@ -142,13 +142,12 @@ that make it longer than the length. If the list is shorter than the
length, do nothing.
> trunc 2 "Hello" -> "He"
+
+This is the same as Data.List.take.
-}
trunc :: Int -> [a] -> [a]
-trunc maxlen list =
- let removecount = (length list) - maxlen in
- if (removecount < 1) then list
- else reverse $ drop removecount $ reverse list
+trunc = take
{- | Adds the specified (key, value) pair to the given list, removing any
existing pair with the same key already present. -}
diff --git a/libsrc/MissingH/Network/FTP/Parser.hs b/libsrc/MissingH/Network/FTP/Parser.hs
index 2bf9f93..a83945b 100644
--- a/libsrc/MissingH/Network/FTP/Parser.hs
+++ b/libsrc/MissingH/Network/FTP/Parser.hs
@@ -59,13 +59,13 @@ code = do
codeString :: Parser String
codeString = do
- first <- oneOf "123456789"
+ first <- oneOf "123456789" <?> "3-digit reply code"
remaining <- count 2 digit <?> "3-digit reply code"
return (first : remaining)
specificCode :: Int -> Parser Int
specificCode exp = do
- s <- string (show exp)
+ s <- string (show exp) <?> ("Code " ++ (show exp))
return (read s)
line :: Parser String
@@ -143,3 +143,4 @@ parseGoodReply input =
if (fst reply) >= 400
then error ((show (fst reply)) ++ ": " ++ (join "\n" (snd reply)))
else reply
+
diff --git a/testsrc/Testutil.hs b/testsrc/Testutil.hs
index bea55fb..b370cdb 100644
--- a/testsrc/Testutil.hs
+++ b/testsrc/Testutil.hs
@@ -16,19 +16,26 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-}
-module Testutil(assertRaises) where
+module Testutil(assertRaises, mapassertEqual) where
import HUnit
import qualified Control.Exception
-assertRaises :: Show a => Exception -> IO a -> IO ()
+assertRaises :: Show a => Control.Exception.Exception -> IO a -> IO ()
assertRaises selector action =
let test e = if e == selector
then Just e
else Nothing
in
- result <- tryJust test action
+ do
+ result <- Control.Exception.tryJust test action
case result of
Left e -> return ()
Right x -> assertFailure ("Received " ++ (show x) ++
" instead of expected exception "
++ (show selector))
+mapassertEqual :: (Show b, Eq b) => String -> (a -> b) -> [(a, b)] -> Assertion
+mapassertEqual descrip func [] = return ()
+mapassertEqual descrip func ((inp,result):xs) =
+ do
+ assertEqual descrip result (func inp)
+ mapassertEqual descrip func xs
\ No newline at end of file
--
haskell-testpack
More information about the Pkg-haskell-commits
mailing list