[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:48:42 UTC 2010
The following commit has been merged in the master branch:
commit 4d7ead1752fe6bb56734e69d0491621a919729b7
Author: John Goerzen <jgoerzen at complete.org>
Date: Wed Dec 1 00:24:30 2004 +0100
Checkpointing test conversions
Keywords:
(jgoerzen at complete.org--projects/missingh--head--0.5--patch-125)
diff --git a/ChangeLog b/ChangeLog
index 8d2ec63..35f58dc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,19 @@
# arch-tag: automatic-ChangeLog--jgoerzen at complete.org--projects/missingh--head--0.5
#
+2004-11-30 17:24:30 GMT John Goerzen <jgoerzen at complete.org> patch-125
+
+ Summary:
+ Checkpointing test conversions
+ Revision:
+ missingh--head--0.5--patch-125
+
+
+ modified files:
+ ChangeLog testsrc/MIMETypestest.hs testsrc/Pathtest.hs
+ testsrc/Printftest.hs testsrc/Strtest.hs testsrc/Testutil.hs
+
+
2004-11-30 16:32:17 GMT John Goerzen <jgoerzen at complete.org> patch-124
Summary:
diff --git a/testsrc/MIMETypestest.hs b/testsrc/MIMETypestest.hs
index 65d65ee..413294f 100644
--- a/testsrc/MIMETypestest.hs
+++ b/testsrc/MIMETypestest.hs
@@ -22,19 +22,23 @@ import Data.List
import MissingH.MIMETypes
test_readMIMETypes =
- do
- mtd <- readMIMETypes defaultmtd True "testsrc/mime.types.test"
- let f = \strict inp exp -> exp @=? guessType mtd strict inp
- let fe = \strict inp exp -> (sort exp) @=? sort (guessAllExtensions mtd strict inp)
- f True "foo.bar.baz" (Nothing, Nothing)
- f True "" (Nothing, Nothing)
- f True "foo.ez" (Just "application/andrew-inset", Nothing)
- fe True "application/andrew-inset" [".ez"]
- f True "foo.dv" (Just "video/x-dv", Nothing)
- fe True "video/x-dv" [".dif", ".dv"]
- f True "test.h++" (Just "text/x-c++hdr", Nothing)
- fe True "text/x-c++hdr" [".h++", ".hpp", ".hxx", ".hh"]
- f True "foo.tgz" (Just "application/x-tar", Just "gzip")
+ let omtd = readMIMETypes defaultmtd True "testsrc/mime.types.test"
+ f = \strict inp exp -> TestCase $ do
+ mtd <- omtd
+ exp @=? guessType mtd strict inp
+ fe = \strict inp exp -> TestCase $ do mtd <- omtd
+ (sort exp) @=? sort (guessAllExtensions mtd strict inp)
+ in [
+ f True "foo.bar.baz" (Nothing, Nothing)
+ ,f True "" (Nothing, Nothing)
+ ,f True "foo.ez" (Just "application/andrew-inset", Nothing)
+ ,fe True "application/andrew-inset" [".ez"]
+ ,f True "foo.dv" (Just "video/x-dv", Nothing)
+ ,fe True "video/x-dv" [".dif", ".dv"]
+ ,f True "test.h++" (Just "text/x-c++hdr", Nothing)
+ ,fe True "text/x-c++hdr" [".h++", ".hpp", ".hxx", ".hh"]
+ ,f True "foo.tgz" (Just "application/x-tar", Just "gzip")
+ ]
test_guessAllExtensions =
@@ -65,5 +69,5 @@ test_guessType =
tests = TestList [TestLabel "guessType" (TestCase test_guessType),
TestLabel "guessAllExtensions" (TestCase test_guessAllExtensions),
- TestLabel "readMIMETypes" (TestCase test_readMIMETypes)
+ TestLabel "readMIMETypes" (TestList test_readMIMETypes)
]
diff --git a/testsrc/Pathtest.hs b/testsrc/Pathtest.hs
index 8c2c4a2..b020fb7 100644
--- a/testsrc/Pathtest.hs
+++ b/testsrc/Pathtest.hs
@@ -21,14 +21,15 @@ import HUnit
import MissingH.Path
test_splitExt =
- let f inp exp = exp @=? splitExt inp in
- do
- f "" ("", "")
- f "/usr/local" ("/usr/local", "")
- f "../foo.txt" ("../foo", ".txt")
- f "../bar.txt.gz" ("../bar.txt", ".gz")
- f "foo.txt/bar" ("foo.txt/bar", "")
- f "foo.txt/bar.bz" ("foo.txt/bar", ".bz")
+ let f inp exp = TestCase $ exp @=? splitExt inp in
+ [
+ f "" ("", "")
+ ,f "/usr/local" ("/usr/local", "")
+ ,f "../foo.txt" ("../foo", ".txt")
+ ,f "../bar.txt.gz" ("../bar.txt", ".gz")
+ ,f "foo.txt/bar" ("foo.txt/bar", "")
+ ,f "foo.txt/bar.bz" ("foo.txt/bar", ".bz")
+ ]
-tests = TestList [TestLabel "splitExt" (TestCase test_splitExt)
+tests = TestList [TestLabel "splitExt" (TestList test_splitExt)
]
\ No newline at end of file
diff --git a/testsrc/Printftest.hs b/testsrc/Printftest.hs
index ebdcba1..ca55645 100644
--- a/testsrc/Printftest.hs
+++ b/testsrc/Printftest.hs
@@ -22,72 +22,76 @@ import MissingH.Printf
import Data.FiniteMap
test_vsprintf =
- do
- "" @=? vsprintf ""
- "%" @=? vsprintf "%%"
- "asdf" @=? vsprintf "%s" "asdf"
- "foo: 5" @=? vsprintf "%s: %d" "foo" (5::Integer)
- "%foo%:% %-1%\n%" @=? vsprintf "%%%s%%:%% %%%d%%\n%%" "foo" (-1::Integer)
- "baz: 3.140000" @=? vsprintf "%s: %f" "baz" (3.14::Double)
- "quux: 3.140000e+02" @=? vsprintf "%s: %e" "quux" (314::Double)
- "fe" @=? vsprintf "%x" (254::Integer)
- "FE" @=? vsprintf "%X" (254::Integer)
- "10" @=? vsprintf "%o" (8::Integer)
- "Hello" @=? vsprintf "Hello"
- "Hello, John\n" @=? vsprintf "Hello, %s\n" "John"
- "John, your age is 10\n" @=? vsprintf "%s, your age is %d\n" "John" (10::Integer)
- "Hello" @=? sprintf "Hello" []
- "Hello, John\n" @=? sprintf "Hello, %s\n" [v "John"]
- "John, your age is 10\n" @=? sprintf "%s, your age is %d\n" [v "John",
+ map TestCase [
+ "" @=? vsprintf ""
+ ,"%" @=? vsprintf "%%"
+ ,"asdf" @=? vsprintf "%s" "asdf"
+ ,"foo: 5" @=? vsprintf "%s: %d" "foo" (5::Integer)
+ ,"%foo%:% %-1%\n%" @=? vsprintf "%%%s%%:%% %%%d%%\n%%" "foo" (-1::Integer)
+ ,"baz: 3.140000" @=? vsprintf "%s: %f" "baz" (3.14::Double)
+ ,"quux: 3.140000e+02" @=? vsprintf "%s: %e" "quux" (314::Double)
+ ,"fe" @=? vsprintf "%x" (254::Integer)
+ ,"FE" @=? vsprintf "%X" (254::Integer)
+ ,"10" @=? vsprintf "%o" (8::Integer)
+ ,"Hello" @=? vsprintf "Hello"
+ ,"Hello, John\n" @=? vsprintf "Hello, %s\n" "John"
+ ,"John, your age is 10\n" @=? vsprintf "%s, your age is %d\n" "John" (10::Integer)
+ ,"Hello" @=? sprintf "Hello" []
+ ,"Hello, John\n" @=? sprintf "Hello, %s\n" [v "John"]
+ ,"John, your age is 10\n" @=? sprintf "%s, your age is %d\n" [v "John",
v (10::Integer)]
+ ]
test_al_fm =
let testal = [("foo", v (1::Int)),
("bar", v "asdf"),
("baz", v (3.14::Double))]
testfm = listToFM testal
- f exp inp = do
- exp @=? sprintfAL inp testal
- exp @=? sprintfFM inp testfm
- in do
- f "" ""
- f "%" "%%"
- f "asdf" "%(bar)s"
- f "001" "%(foo)03d"
- f "asdf " "%(bar)-5s"
- f "3.140" "%(baz).3f"
- f "%asdf%" "%%%(bar)s%%"
- f "Str: asdf % Int: 1" "Str: %(bar)s %% Int: %(foo)d"
+ f exp inp = TestList $ [
+ TestCase $ exp @=? sprintfAL inp testal,
+ TestCase $ exp @=? sprintfFM inp testfm]
+ in [
+ f "" ""
+ ,f "%" "%%"
+ ,f "asdf" "%(bar)s"
+ ,f "001" "%(foo)03d"
+ ,f "asdf " "%(bar)-5s"
+ ,f "3.140" "%(baz).3f"
+ ,f "%asdf%" "%%%(bar)s%%"
+ ,f "Str: asdf % Int: 1" "Str: %(bar)s %% Int: %(foo)d"
+ ]
test_vsprintf_generics =
- do
- "foo: 5" @=? vsprintf "%s: %d" "foo" (5::Int)
- "%foo%:% %-1%\n%" @=? vsprintf "%%%s%%:%% %%%d%%\n%%" "foo" (-1::Integer)
- "baz: 3.140000" @=? vsprintf "%s: %f" "baz" (3.14::Rational)
- "quux: 3.140000e+02" @=? vsprintf "%s: %e" "quux" (314::Double)
- "fe" @=? vsprintf "%x" (254::Int)
- "FE" @=? vsprintf "%X" (254::Int)
- "10" @=? vsprintf "%o" (8::Int)
- "10 3.140" @=? sprintf "%d %.3f" [v (10::Int), v (3.14::Float)]
+ map TestCase [
+ "foo: 5" @=? vsprintf "%s: %d" "foo" (5::Int)
+ ,"%foo%:% %-1%\n%" @=? vsprintf "%%%s%%:%% %%%d%%\n%%" "foo" (-1::Integer)
+ ,"baz: 3.140000" @=? vsprintf "%s: %f" "baz" (3.14::Rational)
+ ,"quux: 3.140000e+02" @=? vsprintf "%s: %e" "quux" (314::Double)
+ ,"fe" @=? vsprintf "%x" (254::Int)
+ ,"FE" @=? vsprintf "%X" (254::Int)
+ ,"10" @=? vsprintf "%o" (8::Int)
+ ,"10 3.140" @=? sprintf "%d %.3f" [v (10::Int), v (3.14::Float)]
+ ]
test_vsprintf_strings =
- do
- ". ." @=? vsprintf ".%5s." ""
- " " @=? vsprintf "%5s" ""
- " " @=? vsprintf "%-5s" ""
- " x" @=? vsprintf "%5s" "x"
- "x " @=? vsprintf "%-5s" "x"
- "abcde" @=? vsprintf "%.5s" "abcde"
- "abcde" @=? vsprintf "%.5s" "abcdef"
- "abcde" @=? vsprintf "%.5s" "abcdefghij"
- "abcde" @=? vsprintf "%5.5s" "abcdefg"
- " abcde" @=? vsprintf "%6.5s" "abcdefg"
- "abcde " @=? vsprintf "%-6.5s" "abcdefg"
+ map TestCase [
+ ". ." @=? vsprintf ".%5s." ""
+ ," " @=? vsprintf "%5s" ""
+ ," " @=? vsprintf "%-5s" ""
+ ," x" @=? vsprintf "%5s" "x"
+ ,"x " @=? vsprintf "%-5s" "x"
+ ,"abcde" @=? vsprintf "%.5s" "abcde"
+ ,"abcde" @=? vsprintf "%.5s" "abcdef"
+ ,"abcde" @=? vsprintf "%.5s" "abcdefghij"
+ ,"abcde" @=? vsprintf "%5.5s" "abcdefg"
+ ," abcde" @=? vsprintf "%6.5s" "abcdefg"
+ ,"abcde " @=? vsprintf "%-6.5s" "abcdefg"
+ ]
-- TODO: test numeric types
-tests = TestList [TestLabel "vsprintf" (TestCase test_vsprintf),
- TestLabel "vsprintf generics" (TestCase test_vsprintf_generics),
- TestLabel "vsprintf strings" (TestCase test_vsprintf_strings),
- TestLabel "vsprintf AL&FM" (TestCase test_al_fm)
+tests = TestList [TestLabel "vsprintf" (TestList test_vsprintf),
+ TestLabel "vsprintf generics" (TestList test_vsprintf_generics),
+ TestLabel "vsprintf strings" (TestList test_vsprintf_strings),
+ TestLabel "vsprintf AL&FM" (TestList test_al_fm)
]
\ No newline at end of file
diff --git a/testsrc/Strtest.hs b/testsrc/Strtest.hs
index 7b6750b..3d44372 100644
--- a/testsrc/Strtest.hs
+++ b/testsrc/Strtest.hs
@@ -52,30 +52,32 @@ test_strip =
("abc def", "abc def")]
test_splitRe =
- let f re inp exp = exp @=? splitRe (mkRegex re) inp
- in do
- f "foo" "" []
- f "foo" "foo" ["", ""]
- f "," "foo,bar,,baz," ["foo", "bar", "", "baz", ""]
- f "ba" ",foo,bar,,baz," [",foo,","r,,","z,"]
- f "," "" []
- f "," "," ["", ""]
+ let f re inp exp = TestCase $ exp @=? splitRe (mkRegex re) inp
+ in [
+ f "foo" "" []
+ ,f "foo" "foo" ["", ""]
+ ,f "," "foo,bar,,baz," ["foo", "bar", "", "baz", ""]
+ ,f "ba" ",foo,bar,,baz," [",foo,","r,,","z,"]
+ ,f "," "" []
+ ,f "," "," ["", ""]
+ ]
test_subRe =
- let f re inp repl exp = exp @=? subRe (mkRegex re) inp repl
- in do
- f "foo" "" "bar" ""
- f "foo" "This is a foo test bar" "bar" "This is a bar test bar"
- f "foo" "Test foo bar" "x\\0x" "Test xfoox bar"
- f "(f)(o)o" "Test foo bar" "\\2\\1" "Test of bar"
- f "foo" "Test foo then foo bar" "" "Test then bar"
- f "foo" "Test foo bar" "x\\\\x" "Test x\\x bar"
+ let f re inp repl exp = TestCase $ exp @=? subRe (mkRegex re) inp repl
+ in [
+ f "foo" "" "bar" ""
+ ,f "foo" "This is a foo test bar" "bar" "This is a bar test bar"
+ ,f "foo" "Test foo bar" "x\\0x" "Test xfoox bar"
+ ,f "(f)(o)o" "Test foo bar" "\\2\\1" "Test of bar"
+ ,f "foo" "Test foo then foo bar" "" "Test then bar"
+ ,f "foo" "Test foo bar" "x\\\\x" "Test x\\x bar"
+ ]
-tests = TestList [TestLabel "lstrip" (TestCase test_lstrip),
- TestCase test_rstrip,
- TestCase test_strip,
- TestCase test_subRe,
- TestCase test_splitRe
+tests = TestList [TestLabel "lstrip" (TestList test_lstrip),
+ TestLabel "rstrip" $ TestList test_rstrip,
+ TestLabel "strip" $ TestList test_strip,
+ TestLabel "subRe" $ TestList test_subRe,
+ TestLabel "splitRe" $ TestList test_splitRe
]
diff --git a/testsrc/Testutil.hs b/testsrc/Testutil.hs
index 5683c24..889cb94 100644
--- a/testsrc/Testutil.hs
+++ b/testsrc/Testutil.hs
@@ -31,9 +31,7 @@ assertRaises msg selector action =
Left e -> thetest e
Right x -> assertFailure $ msg ++ "\nReceived no exception, but was expecting exception: " ++ (show selector)
-mapassertEqual :: (Show b, Eq b) => String -> (a -> b) -> [(a, b)] -> Assertion
-mapassertEqual descrip func [] = return ()
+mapassertEqual :: (Show b, Eq b) => String -> (a -> b) -> [(a, b)] -> [Test]
+mapassertEqual descrip func [] = []
mapassertEqual descrip func ((inp,result):xs) =
- do
- assertEqual descrip result (func inp)
- mapassertEqual descrip func xs
\ No newline at end of file
+ (TestCase $ 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