Last active
December 22, 2015 03:58
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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