[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:41 UTC 2010
The following commit has been merged in the master branch:
commit 9764cf06ac613e4f23b29ad5438dab9121f907cf
Author: John Goerzen <jgoerzen at complete.org>
Date: Tue Nov 30 23:32:17 2004 +0100
More tests and fixes
Keywords:
(jgoerzen at complete.org--projects/missingh--head--0.5--patch-124)
diff --git a/ChangeLog b/ChangeLog
index 7a76e3c..8d2ec63 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:32:17 GMT John Goerzen <jgoerzen at complete.org> patch-124
+
+ Summary:
+ More tests and fixes
+ Revision:
+ missingh--head--0.5--patch-124
+
+
+ modified files:
+ ChangeLog TODO libsrc/MissingH/ConfigParser/Types.hs
+ testsrc/ConfigParser/Maintest.hs
+
+
2004-11-30 16:21:55 GMT John Goerzen <jgoerzen at complete.org> patch-123
Summary:
diff --git a/TODO b/TODO
index f80eb0b..866b03c 100644
--- a/TODO
+++ b/TODO
@@ -1,6 +1,6 @@
arch-tag: TODO file
-START WITH: test_defaults from OCaml
+START WITH: test_interpolate from OCaml
Printf:
make %H work
diff --git a/libsrc/MissingH/ConfigParser/Types.hs b/libsrc/MissingH/ConfigParser/Types.hs
index b68595f..4520633 100644
--- a/libsrc/MissingH/ConfigParser/Types.hs
+++ b/libsrc/MissingH/ConfigParser/Types.hs
@@ -124,13 +124,16 @@ defdefaulthandler :: ConfigParser -> SectionSpec -> OptionSpec -> CPResult Strin
defdefaulthandler cp sect opt =
let fm = content cp
lookup :: SectionSpec -> OptionSpec -> CPResult String
- lookup s o = do sect <- maybeToEither (NoSection s, "lookup handler") $ lookupFM fm s
- maybeToEither (NoOption o, "lookup handler") $ lookupFM sect o
+ lookup s o = do sect <- maybeToEither (NoSection s, "get") $ lookupFM fm s
+ maybeToEither (NoOption o, "get") $ lookupFM sect o
trydefault :: CPError -> CPResult String
trydefault e = if (usedefault cp)
- then lookup "DEFAULT" opt
+ then
+ lookup "DEFAULT" opt
+ -- Use original error if it's not in DEFAULT either
+ `catchError` (\_ -> throwError e)
else throwError e
- in
+ in
lookup sect opt `catchError` trydefault
{- | Low-level tool to convert a parsed object into a 'CPData'
diff --git a/testsrc/ConfigParser/Maintest.hs b/testsrc/ConfigParser/Maintest.hs
index efd222e..ed46728 100644
--- a/testsrc/ConfigParser/Maintest.hs
+++ b/testsrc/ConfigParser/Maintest.hs
@@ -69,10 +69,18 @@ test_basic =
test_defaults =
- let cp = p "def: ault\n[sect1]\nfoo: bar\nbaz: quuz\nint: 2\nfloat: 3\nbool: yes" in
+ let cp = p "def: ault\n[sect1]\nfoo: bar\nbaz: quuz\nint: 2\nfloat: 3\nbool: yes\n[sect4]\ndef: different" in
[
f2 "default item" (Right "ault") (get cp "sect1" "def")
-
+ ,f2 "normal item" (Right "bar") (get cp "sect1" "foo")
+ ,f2 "no option" (Left (NoOption "abc", "get")) (get cp "sect1" "abc")
+ ,f2 "no section" (Left (NoSection "sect2", "get")) (get cp "sect2" "foo")
+ ,f2 "default from bad sect" (Right "ault") (get cp "sect2" "def")
+ ,f2 "overriding default" (Right "different") (get cp "sect4" "def")
+ -- not in haskell: ,f2 "using default feature"
+ -- default int
+ -- default float
+ -- default bool
]
--
haskell-testpack
More information about the Pkg-haskell-commits
mailing list