Commit d88efb70 authored by Tamar Christina's avatar Tamar Christina

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
parent c4808602
......@@ -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
-- ---------------------------------------------------------------------
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment