On Thu, Sep 29, 2011 at 06:01:20PM +0200, Agata Murawska wrote:
> On Mon, Sep 26, 2011 at 11:57 AM, Iustin Pop <[email protected]> wrote:
> > This makes error message change from "Test 4 failed …" to "Test
> > prop_Loader_mergeData failed", which is much more readable. It also
> > removes the duplication of test suite names in the test.hs file.
> > ---
> >  htools/Ganeti/HTools/QC.hs       |  194 
> > +++++++++++++++++++-------------------
> >  htools/Ganeti/HTools/QCHelper.hs |   47 +++++++++
> >  htools/test.hs                   |   64 +++++++------
> >  3 files changed, 178 insertions(+), 127 deletions(-)
> >  create mode 100644 htools/Ganeti/HTools/QCHelper.hs
> > +testSuite :: String -> [Name] -> Q [Dec]
> > +testSuite tsname tdef = do
> > +  let fullname = mkName $ "test" ++ tsname
> > +  tests <- mapM (\n -> [| (run $(varE n), $(litE (StringL (nameBase n)))) 
> > |])
> > +           tdef
> > +  sigtype <- [t| (String, [(Args -> IO Result, String)]) |]
> > +  return $ [ SigD fullname sigtype
> > +           , ValD (VarP fullname) (NormalB (TupE [LitE (StringL tsname),
> > +                                                  ListE tests])) []
> > +           ]

> This I find little hard to read, because of the brackets (especially
> tests <- ..). And yes, I am a huge fan of '.' and '$' ;)

I changed tests <-, but I can't change the ValD … because there are (
interspersed with [, and hence a direct conversion to point-free style
won't work here. Suggestions welcome, in the meantime the interdiff is:


diff --git a/htools/Ganeti/HTools/QCHelper.hs b/htools/Ganeti/HTools/QCHelper.hs
index 5057b5f..cabf88c 100644
--- a/htools/Ganeti/HTools/QCHelper.hs
+++ b/htools/Ganeti/HTools/QCHelper.hs
@@ -38,7 +38,7 @@ run = flip quickCheckWithResult
 testSuite :: String -> [Name] -> Q [Dec]
 testSuite tsname tdef = do
   let fullname = mkName $ "test" ++ tsname
-  tests <- mapM (\n -> [| (run $(varE n), $(litE (StringL (nameBase n)))) |])
+  tests <- mapM (\n -> [| (run $(varE n), $(litE . StringL . nameBase $ n)) |])
            tdef
   sigtype <- [t| (String, [(Args -> IO Result, String)]) |]
   return $ [ SigD fullname sigtype

-- 
iustin

Reply via email to