[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:40 UTC 2010
The following commit has been merged in the master branch:
commit 5a9bde677e3ee7bb241aa1c349cb0bbcc14ec660
Author: John Goerzen <jgoerzen at complete.org>
Date: Tue Nov 30 23:21:55 2004 +0100
More tests, slight bug fixes
Keywords:
(jgoerzen at complete.org--projects/missingh--head--0.5--patch-123)
diff --git a/ChangeLog b/ChangeLog
index 3b592cc..7a76e3c 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 16:21:55 GMT John Goerzen <jgoerzen at complete.org> patch-123
+
+ Summary:
+ More tests, slight bug fixes
+ Revision:
+ missingh--head--0.5--patch-123
+
+
+ modified files:
+ ChangeLog TODO libsrc/MissingH/ConfigParser.hs
+ testsrc/ConfigParser/Maintest.hs
+
+
2004-11-30 15:40:16 GMT John Goerzen <jgoerzen at complete.org> patch-122
Summary:
diff --git a/TODO b/TODO
index e2888d9..f80eb0b 100644
--- a/TODO
+++ b/TODO
@@ -9,6 +9,6 @@ test configparser:
* with various default options
* exception system
-test Either.hs
+document configparser
tests for new Parsec stuff
diff --git a/libsrc/MissingH/ConfigParser.hs b/libsrc/MissingH/ConfigParser.hs
index 6eed7f6..107b46c 100644
--- a/libsrc/MissingH/ConfigParser.hs
+++ b/libsrc/MissingH/ConfigParser.hs
@@ -49,6 +49,9 @@ module MissingH.ConfigParser
-- * Setting Data
set, setshow,
+ -- * Output Data
+ to_string,
+
-- * Meta-queries
sections, has_section,
options, has_option,
@@ -283,10 +286,12 @@ later re-parsed by this module. -}
to_string :: ConfigParser -> String
to_string cp =
let gen_option (key, value) =
- key ++ ": " ++ (replace "\n" "\n " value) ++ "\n"
- gen_section (sect, valfm) =
- "[" ++ sect ++ "]\n" ++
- (concat $ map gen_option (fmToList valfm)) ++ "\n"
+ key ++ ": " ++ (replace "\n" "\n " value) ++ "\n"
+ gen_section (sect, valfm) = -- gen a section, but omit DEFAULT if empty
+ if (sect /= "DEFAULT") || (sizeFM valfm > 0)
+ then "[" ++ sect ++ "]\n" ++
+ (concat $ map gen_option (fmToList valfm)) ++ "\n"
+ else ""
in
concat $ map gen_section (fmToList (content cp))
diff --git a/testsrc/ConfigParser/Maintest.hs b/testsrc/ConfigParser/Maintest.hs
index b59dded..efd222e 100644
--- a/testsrc/ConfigParser/Maintest.hs
+++ b/testsrc/ConfigParser/Maintest.hs
@@ -61,12 +61,18 @@ test_basic =
Right "o1" @=? get cp "sect1" "v1"
Right "o2" @=? get cp "sect1" "v2"
Right "o1" @=? get cp "DEFAULT" "v1"
+ , f3 "extensions to string"
+ "[sect1]\nfoo: bar\nbaz: l1\n l2\n l3\n# c\nquux: asdf"
+ "[sect1]\nbaz: l1\n l2\n l3\nfoo: bar\nquux: asdf\n\n"
+ to_string
]
+
test_defaults =
let cp = p "def: ault\n[sect1]\nfoo: bar\nbaz: quuz\nint: 2\nfloat: 3\nbool: yes" in
[
f2 "default item" (Right "ault") (get cp "sect1" "def")
+
]
--
haskell-testpack
More information about the Pkg-haskell-commits
mailing list