summaryrefslogtreecommitdiff
path: root/utils/check-ppr
diff options
context:
space:
mode:
authorTamar Christina <tamar@zhox.com>2016-12-17 16:40:11 +0000
committerTamar Christina <tamar@zhox.com>2016-12-17 19:21:44 +0000
commitd88efb7048160c3031eadb4f3b729e9fe406414d (patch)
tree9601a1de546a182c0750b3f265c1e4acbbeb32c6 /utils/check-ppr
parentc4808602124577217dbd39576c120a77f923ca6f (diff)
downloadhaskell-d88efb7048160c3031eadb4f3b729e9fe406414d.tar.gz
Fix Pretty printer tests on Windows
Summary: D2752 added some tests which escapes string literals. This means newlines are converted before they get normalized by the IO functions. So on Windows \r\n would be in the output while \n was expected. Test Plan: make test -C testsuite/tests/printer Reviewers: austin, bgamari, alanz Reviewed By: alanz Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2873 GHC Trac Issues: #3384
Diffstat (limited to 'utils/check-ppr')
-rw-r--r--utils/check-ppr/Main.hs15
1 files changed, 10 insertions, 5 deletions
diff --git a/utils/check-ppr/Main.hs b/utils/check-ppr/Main.hs
index 8c937695cc..c9fac7dc33 100644
--- a/utils/check-ppr/Main.hs
+++ b/utils/check-ppr/Main.hs
@@ -132,10 +132,10 @@ showAstData n =
space "" = ""
space s = ' ':s
indent i = "\n" ++ replicate i ' '
- string = show :: String -> String
- fastString = ("{FastString: "++) . (++"}") . show
+ string = normalize_newlines . show :: String -> String
+ fastString = ("{FastString: "++) . (++"}") . normalize_newlines . show
:: FastString -> String
- bytestring = show :: B.ByteString -> String
+ bytestring = normalize_newlines . show :: B.ByteString -> String
list l = indent n ++ "["
++ intercalate "," (map (showAstData (n+1)) l)
++ "]"
@@ -179,11 +179,16 @@ showAstData n =
++ showAstData (n+1) a
++ ")"
+normalize_newlines :: String -> String
+normalize_newlines ('\\':'r':'\\':'n':xs) = '\\':'n':normalize_newlines xs
+normalize_newlines (x:xs) = x:normalize_newlines xs
+normalize_newlines [] = []
+
showSDoc_ :: SDoc -> String
-showSDoc_ = showSDoc unsafeGlobalDynFlags
+showSDoc_ = normalize_newlines . showSDoc unsafeGlobalDynFlags
showSDocDebug_ :: SDoc -> String
-showSDocDebug_ = showSDocDebug unsafeGlobalDynFlags
+showSDocDebug_ = normalize_newlines . showSDocDebug unsafeGlobalDynFlags
-- ---------------------------------------------------------------------