[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:47:36 UTC 2010
The following commit has been merged in the master branch:
commit 10b988988d1cbc925bdf8d691cf6940505b8e5ff
Author: John Goerzen <jgoerzen at complete.org>
Date: Fri Nov 19 02:10:38 2004 +0100
Fixed assertRaises
Keywords:
(jgoerzen at complete.org--projects/missingh--head--0.5--patch-79)
diff --git a/ChangeLog b/ChangeLog
index 26b50ce..9dfe23d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,19 @@
# arch-tag: automatic-ChangeLog--jgoerzen at complete.org--projects/missingh--head--0.5
#
+2004-11-18 19:10:38 GMT John Goerzen <jgoerzen at complete.org> patch-79
+
+ Summary:
+ Fixed assertRaises
+ Revision:
+ missingh--head--0.5--patch-79
+
+
+ modified files:
+ ChangeLog testsrc/ConfigParser/Parsertest.hs
+ testsrc/Testutil.hs
+
+
2004-11-18 18:44:55 GMT John Goerzen <jgoerzen at complete.org> patch-78
Summary:
diff --git a/testsrc/ConfigParser/Parsertest.hs b/testsrc/ConfigParser/Parsertest.hs
index c1e2c1d..36edca2 100644
--- a/testsrc/ConfigParser/Parsertest.hs
+++ b/testsrc/ConfigParser/Parsertest.hs
@@ -20,6 +20,7 @@ module ConfigParser.Parsertest(tests) where
import HUnit
import MissingH.ConfigParser.Parser
import Testutil
+import Control.Exception
test_basic =
let f inp exp = exp @=? parse_string inp in
@@ -35,6 +36,10 @@ test_basic =
[("Cemptysect", [])]
f "[emptysect]\n# [nonexistant]\n" [("emptysect", [])]
f "[sect1]\nfoo: bar\n" [("sect1", [("foo", "bar")])]
+ f "\n#foo\n[sect1]\n\n#iiii \no1: v1\no2: v2\n o3: v3"
+ [("sect1", [("o1", "v1"), ("o2", "v2"), ("o3", "v3")])]
+ assertRaises (ErrorCall "Lexer: \"(string)\" (line 1, column 5):\nunexpected \"\\n\"\nexpecting Option separator")
+ (f "#foo\nthis is bad data" [])
f "foo: bar" [("DEFAULT", [("foo", "bar")])]
tests = TestList [TestLabel "test_basic" (TestCase test_basic)
diff --git a/testsrc/Testutil.hs b/testsrc/Testutil.hs
index b370cdb..136643d 100644
--- a/testsrc/Testutil.hs
+++ b/testsrc/Testutil.hs
@@ -22,17 +22,15 @@ import qualified Control.Exception
assertRaises :: Show a => Control.Exception.Exception -> IO a -> IO ()
assertRaises selector action =
- let test e = if e == selector
- then Just e
- else Nothing
- in
- 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))
+ let thetest e = if e == selector then return ()
+ else assertFailure $ "Received unexpected exception: "
+ ++ (show e) ++ "\ninstead of exception: " ++ (show selector)
+ in do
+ r <- Control.Exception.try action
+ case r of
+ Left e -> thetest e
+ Right x -> assertFailure $ "Received no exception, but was expecting exception: " ++ (show selector)
+
mapassertEqual :: (Show b, Eq b) => String -> (a -> b) -> [(a, b)] -> Assertion
mapassertEqual descrip func [] = return ()
mapassertEqual descrip func ((inp,result):xs) =
--
haskell-testpack
More information about the Pkg-haskell-commits
mailing list