Skip to content
Snippets Groups Projects
Commit 147fd319 authored by Iustin Pop's avatar Iustin Pop
Browse files

Expand TestHelper to allow non-underscore prefixes


HLint 1.8.28 requires us to always add "ignore CamelCase", which can
be problematic sometimes (e.g. when using OverloadedStrings). Let's
expand TestHelper to also support less-standard 'caseFooBar' names, so
that we can remove the annotations.

Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarHelga Velroyen <helgav@google.com>
parent 87f1a454
No related branches found
No related tags found
No related merge requests found
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
{- {-
Copyright (C) 2011, 2012 Google Inc. Copyright (C) 2011, 2012, 2013 Google Inc.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
...@@ -48,6 +48,10 @@ propPrefix = "prop_" ...@@ -48,6 +48,10 @@ propPrefix = "prop_"
casePrefix :: String casePrefix :: String
casePrefix = "case_" casePrefix = "case_"
-- | Test case prefix without underscore.
case2Pfx :: String
case2Pfx = "case"
-- | Tries to drop a prefix from a string. -- | Tries to drop a prefix from a string.
simplifyName :: String -> String -> String simplifyName :: String -> String -> String
simplifyName pfx string = fromMaybe string (stripPrefix pfx string) simplifyName pfx string = fromMaybe string (stripPrefix pfx string)
...@@ -70,6 +74,8 @@ run name = ...@@ -70,6 +74,8 @@ run name =
in case () of in case () of
_ | propPrefix `isPrefixOf` str -> [| runProp $strE $nameE |] _ | propPrefix `isPrefixOf` str -> [| runProp $strE $nameE |]
| casePrefix `isPrefixOf` str -> [| runCase $strE $nameE |] | casePrefix `isPrefixOf` str -> [| runCase $strE $nameE |]
| case2Pfx `isPrefixOf` str ->
[| (testCase . simplifyName case2Pfx) $strE $nameE |]
| otherwise -> fail $ "Unsupported test function name '" ++ str ++ "'" | otherwise -> fail $ "Unsupported test function name '" ++ str ++ "'"
-- | Convert slashes in a name to underscores. -- | Convert slashes in a name to underscores.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment