On Wed, Feb 06, 2013 at 01:10:46PM +0100, Michele Tartara wrote: > In order to fetch precise information about the uptime of the VMs > running in Xen, we need to analyze the output of the "xm uptime" command. > > This commit adds the parser to do that, and its tests. > +-- | Test whether a randomly generated UptimeInfo text line can be parsed. > +prop_uptimeInfo :: UptimeInfo -> Property > +prop_uptimeInfo uInfo = > + case A.parseOnly uptimeLineParser . pack . serializeUptime $ uInfo of > + Left msg -> fail $ "Parsing failed: " ++ msg > + Right obtained -> obtained ==? uInfo
You have a lot of this construct. Why not add a function: eitherCheck :: Either String b -> (b -> Property) -> Property eitherCheck (Left msg) _ = fail $ "Parsing failed: " ++ msg eitherCheck (Right v) prop = prop v and simplify the tests? In any case, LGTM. iustin
