Skip to content

Instantly share code, notes, and snippets.

@agrafix
Last active December 22, 2015 03:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agrafix/6413629 to your computer and use it in GitHub Desktop.
Save agrafix/6413629 to your computer and use it in GitHub Desktop.
testRegex fails using GHC 7.6.1 and regex-pcre 0.94.4
import Text.Regex.PCRE
regex = "dein(en)? ([^\\s]+)"
expected = [ [ "dein F\252ller", "", "F\252ller"]
, [ "deinen F\246hn", "en", "F\246hn"]
]
-- consider this being read from a file
inputStr = "Nimm dein F\252ller und nimm deinen F\246hn mit."
-- this failes
testRegex :: IO ()
testRegex =
quickAssert "Regex with umlauts" expected got
where
got :: [[String]]
got = inputStr =~ regex
-- just a helper
quickAssert :: (Show a, Eq a) => String -> a -> a -> IO ()
quickAssert name expect got
| expect == got = putStrLn $ "> " ++ name ++ ": OK"
| otherwise =
do putStrLn $ "> " ++ name ++ ": FAILED"
putStrLn $ "Expected: " ++ show expect
putStrLn $ "Got: " ++ show got
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment