[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:49:03 UTC 2010


The following commit has been merged in the master branch:
commit a5fae0e33c6c7f4c2ba4999fd5f14ccd133fabd6
Author: John Goerzen <jgoerzen at complete.org>
Date:   Thu Dec 2 03:42:42 2004 +0100

    Tested more ConfigParser stuff
    
    Keywords:
    
    
    (jgoerzen at complete.org--projects/missingh--head--0.5--patch-141)

diff --git a/ChangeLog b/ChangeLog
index d902bb0..8df8a42 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,18 @@
 # arch-tag: automatic-ChangeLog--jgoerzen at complete.org--projects/missingh--head--0.5
 #
 
+2004-12-01 20:42:42 GMT	John Goerzen <jgoerzen at complete.org>	patch-141
+
+    Summary:
+      Tested more ConfigParser stuff
+    Revision:
+      missingh--head--0.5--patch-141
+
+
+    modified files:
+     ChangeLog TODO testsrc/ConfigParser/Maintest.hs
+
+
 2004-12-01 19:20:35 GMT	John Goerzen <jgoerzen at complete.org>	patch-140
 
     Summary:
diff --git a/TODO b/TODO
index 830e379..2582131 100644
--- a/TODO
+++ b/TODO
@@ -1,15 +1,6 @@
 arch-tag: TODO file
 
-START WITH: test_interpolate from OCaml
 Printf:
  make %H work 
 
-test configparser:
- * according to ocaml spec
- * with various default options
- * exception system
- * remove_*
-
-document configparser
-
 tests for new Parsec stuff
diff --git a/testsrc/ConfigParser/Maintest.hs b/testsrc/ConfigParser/Maintest.hs
index 21b64f9..c83aa94 100644
--- a/testsrc/ConfigParser/Maintest.hs
+++ b/testsrc/ConfigParser/Maintest.hs
@@ -31,6 +31,12 @@ f msg inp exp conv = TestLabel msg $ TestCase $ assertEqual "" (Right exp) (conv
 f2 msg exp res = TestLabel msg $ TestCase $ assertEqual "" exp res
 f3 msg inp exp conv = TestLabel msg $ TestCase $ assertEqual "" exp (conv (p inp))
 
+instance Show ConfigParser where
+    show x = show (content x)
+
+instance Eq ConfigParser where
+    x == y = (content x) == (content y)
+
 test_basic =
         [
          f3 "empty doc, no sections" "" [] sections,
@@ -101,6 +107,39 @@ test_nodefault =
       -- default bool
       ]
 
+test_remove = 
+    let cp = forceEither $ readstring emptyCP "def:ault\n[sect1]\ns1o1: v1\ns1o2:v2\n[sect2]\ns2o1: v1\ns2o2: v2\n[sect3]"
+        in [
+            f2 "setup" ["sect1", "sect2", "sect3"] (sections cp)
+           ,f2 "remove 1st s" (Right ["sect2", "sect3"])
+               (do x <- remove_section cp "sect1"
+                   return $ sections x
+                )
+           ,f2 "remove 2nd s" (Right ["sect1", "sect3"])
+               (do x <- remove_section cp "sect2"
+                   return $ sections x
+                )
+           ,f2 "remove 3rd s" (Right ["sect1", "sect2"])
+               (do x <- remove_section cp "sect3"
+                   return $ sections x
+                )
+           ,f2 "error handling s" (Left (NoSection "sect4", "remove_section"))
+                  (remove_section cp "sect4")
+           ,f2 "remove an option" (Right (["sect1", "sect2", "sect3"], ["s1o2"]))
+               (do x <- remove_option cp "sect1" "s1o1"
+                   y <- options x "sect1"
+                   return (sections x, y)
+                )
+           ,f2 "option err 1" (Left (NoSection "sect4", "remove_option"))
+               (remove_option cp "sect4" "s4o1")
+           ,f2 "option err 2" (Left (NoOption "s1o3", "remove_option"))
+               (remove_option cp "sect1" "s1o3")
+           ]
+                  
+        
+       
+              
+
 test_ex_nomonad = 
     do 
        fh <- nullfile
@@ -170,6 +209,7 @@ test_interp =
 tests = TestList [TestLabel "test_basic" (TestList test_basic),
                  TestLabel "test_defaults" (TestList test_defaults),
                  TestLabel "test_nodefault" (TestList test_nodefault),
+                 TestLabel "test_remove" (TestList test_remove),
                  TestLabel "test_ex_nomonad" (TestCase test_ex_nomonad),
                  TestLabel "test_ex_errormonad" (TestList test_ex_errormonad),
                  TestLabel "test_interp" (TestList test_interp)]

-- 
haskell-testpack



More information about the Pkg-haskell-commits mailing list