[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 15:09:30 UTC 2010


The following commit has been merged in the master branch:
commit f886128008f8f83c15039665f0e75636fa3a09be
Author: John Goerzen <jgoerzen at complete.org>
Date:   Mon Apr 10 21:57:39 2006 +0100

    Working on glob and wild test cases

diff --git a/testsrc/Globtest.hs b/testsrc/Globtest.hs
index 852eabe..0d29e84 100644
--- a/testsrc/Globtest.hs
+++ b/testsrc/Globtest.hs
@@ -20,14 +20,47 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 module Globtest(tests) where
 import Test.HUnit
 import MissingH.Path.Glob
+import MissingH.Path
 import MissingH.HUnit
 import MissingH.IO.HVFS
+import System.Posix.Directory
+import System.Posix.Files
+import Control.Exception
+import Data.List
 
-defaultFS :: IO MemoryVFS
-defaultFS =
+bp = "testtmp"
+touch x = writeFile x ""
 
-     
-tests = TestList [TestLabel "wildMatchCase" (TestList test_wildMatchCase)]
+globtest thetest = 
+    bracket_ (setupfs)
+             (recursiveRemove SystemFS bp)
+             thetest
+    where setupfs =
+              do mapM_ (\x -> createDirectory x 0o755)
+                       [bp, bp ++ "/a", bp ++ "/aab", bp ++ "/aaa",
+                        bp ++ "/ZZZ", bp ++ "/a/bcd",
+                        bp ++ "/a/bcd/efg"]
+                 mapM_ touch [bp ++ "/a/D", bp ++ "/aab/F", bp ++ "/aaa/zzzF",
+                              bp ++ "/a/bcd/EF", bp ++ "/a/bcd/efg/ha"]
+                 createSymbolicLink "broken" "sym1"
+                 createSymbolicLink "broken" "sym2"
+                 
+assertEqualSorted msg exp res =
+    assertEqual msg (sort exp) (sort res)
+eq = assertEqualSorted
+mf msg func = TestLabel msg $ TestCase $ globtest func
+f func = TestCase $ globtest func
+preppath x = bp ++ "/" ++ x
+
+test_literal =
+    map f
+            [glob (preppath "a") >>= eq "" [(preppath "a")]
+            ,glob (preppath "a/D") >>= eq "" [(preppath "a/D")]
+            ,glob (preppath "aab") >>= eq "" [(preppath "aab")]
+            ,glob (preppath "nonexistant") >>= eq "empty" []
+            ]
+
+tests = TestList [TestLabel "test_literal" (TestList test_literal)]
 
 
 
diff --git a/testsrc/WildMatchtest.hs b/testsrc/WildMatchtest.hs
index 9572cc5..171c94d 100644
--- a/testsrc/WildMatchtest.hs
+++ b/testsrc/WildMatchtest.hs
@@ -22,11 +22,12 @@ import Test.HUnit
 import MissingH.Path.WildMatch
 import MissingH.HUnit
 
-test_wildMatchCase =
-    let f patt name = assertBool (patt ++ "," ++ name ++ " was false")
-                      (wildMatchCase patt name)
-        f0 patt name = assertBool (patt ++ "," ++ name ++ " was true")
-                       (not $ wildMatchCase patt name)
+test_wildCheckCase =
+    let f patt name = TestCase $ assertBool (patt ++ "," ++ name ++ " was false")
+                      (wildCheckCase patt name)
+        f0 patt name = TestCase $ assertBool (patt ++ "," ++ name ++ " was true")
+                       (not $ wildCheckCase patt name)
+    in
     [f "asdf" "asdf",
      f "?*?" "abc",
      f "???*" "asd",
@@ -40,9 +41,9 @@ test_wildMatchCase =
      f0 "a" "b",
      f "[\\]" "\\",
      f "[!\\]" "a",
-     f0 "[!\\]", "\\"]
+     f0 "[!\\]" "\\"]
      
-tests = TestList [TestLabel "wildMatchCase" (TestList test_wildMatchCase)]
+tests = TestList [TestLabel "wildCheckCase" (TestList test_wildCheckCase)]
 
 
 

-- 
haskell-testpack



More information about the Pkg-haskell-commits mailing list