summaryrefslogtreecommitdiff
path: root/testsuite/tests/ghc-api/annotations-literals
diff options
context:
space:
mode:
authorAlan Zimmerman <alan.zimm@gmail.com>2016-11-08 21:37:48 +0200
committerAlan Zimmerman <alan.zimm@gmail.com>2016-12-07 21:31:13 +0200
commit499e43824bda967546ebf95ee33ec1f84a114a7c (patch)
tree58b313d734cfba014395ea5876db48e8400296a8 /testsuite/tests/ghc-api/annotations-literals
parent83d69dca896c7df1f2a36268d5b45c9283985ebf (diff)
downloadhaskell-499e43824bda967546ebf95ee33ec1f84a114a7c.tar.gz
Add HsSyn prettyprinter tests
Summary: Add prettyprinter tests, which take a file, parse it, pretty print it, re-parse the pretty printed version and then compare the original and new ASTs (ignoring locations) Updates haddock submodule to match the AST changes. There are three issues outstanding 1. Extra parens around a context are not reproduced. This will require an AST change and will be done in a separate patch. 2. Currently if an `HsTickPragma` is found, this is not pretty-printed, to prevent noise in the output. I am not sure what the desired behaviour in this case is, so have left it as before. Test Ppr047 is marked as expected fail for this. 3. Apart from in a context, the ParsedSource AST keeps all the parens from the original source. Something is happening in the renamer to remove the parens around visible type application, causing T12530 to fail, as the dumped splice decl is after the renamer. This needs to be fixed by keeping the parens, but I do not know where they are being removed. I have amended the test to pass, by removing the parens in the expected output. Test Plan: ./validate Reviewers: goldfire, mpickering, simonpj, bgamari, austin Reviewed By: simonpj, bgamari Subscribers: simonpj, goldfire, thomie, mpickering Differential Revision: https://phabricator.haskell.org/D2752 GHC Trac Issues: #3384
Diffstat (limited to 'testsuite/tests/ghc-api/annotations-literals')
-rw-r--r--testsuite/tests/ghc-api/annotations-literals/literals.stdout16
-rw-r--r--testsuite/tests/ghc-api/annotations-literals/parsed.hs38
-rw-r--r--testsuite/tests/ghc-api/annotations-literals/parsed.stdout8
3 files changed, 37 insertions, 25 deletions
diff --git a/testsuite/tests/ghc-api/annotations-literals/literals.stdout b/testsuite/tests/ghc-api/annotations-literals/literals.stdout
index 077c570f2b..0e8ce7c9dc 100644
--- a/testsuite/tests/ghc-api/annotations-literals/literals.stdout
+++ b/testsuite/tests/ghc-api/annotations-literals/literals.stdout
@@ -24,7 +24,7 @@
(LiteralsTest.hs:5:3,ITequal,[=]),
-(LiteralsTest.hs:5:5-8,ITinteger "0003" 3,[0003]),
+(LiteralsTest.hs:5:5-8,ITinteger (SourceText "0003") 3,[0003]),
(LiteralsTest.hs:6:1,ITsemi,[]),
@@ -32,7 +32,7 @@
(LiteralsTest.hs:6:3,ITequal,[=]),
-(LiteralsTest.hs:6:5-8,ITinteger "0x04" 4,[0x04]),
+(LiteralsTest.hs:6:5-8,ITinteger (SourceText "0x04") 4,[0x04]),
(LiteralsTest.hs:8:1,ITsemi,[]),
@@ -48,7 +48,7 @@
(LiteralsTest.hs:9:3,ITequal,[=]),
-(LiteralsTest.hs:9:5-10,ITstring "\"\\x20\"" " ",["\x20"]),
+(LiteralsTest.hs:9:5-10,ITstring (SourceText "\"\\x20\"") " ",["\x20"]),
(LiteralsTest.hs:11:1,ITsemi,[]),
@@ -64,7 +64,7 @@
(LiteralsTest.hs:12:3,ITequal,[=]),
-(LiteralsTest.hs:12:5-10,ITchar "'\\x20'" ' ',['\x20']),
+(LiteralsTest.hs:12:5-10,ITchar (SourceText "'\\x20'") ' ',['\x20']),
(LiteralsTest.hs:14:1,ITsemi,[]),
@@ -98,7 +98,7 @@
(LiteralsTest.hs:19:11,ITequal,[=]),
-(LiteralsTest.hs:19:13-19,ITprimchar "'\\x41'" 'A',['\x41'#]),
+(LiteralsTest.hs:19:13-19,ITprimchar (SourceText "'\\x41'") 'A',['\x41'#]),
(LiteralsTest.hs:20:5,ITsemi,[]),
@@ -106,7 +106,7 @@
(LiteralsTest.hs:20:10,ITequal,[=]),
-(LiteralsTest.hs:20:12-16,ITprimint "0004#" 4,[0004#]),
+(LiteralsTest.hs:20:12-16,ITprimint (SourceText "0004#") 4,[0004#]),
(LiteralsTest.hs:21:5,ITsemi,[]),
@@ -114,7 +114,7 @@
(LiteralsTest.hs:21:11,ITequal,[=]),
-(LiteralsTest.hs:21:13-17,ITprimword "005##" 5,[005##]),
+(LiteralsTest.hs:21:13-17,ITprimword (SourceText "005##") 5,[005##]),
(LiteralsTest.hs:22:5,ITsemi,[]),
@@ -138,7 +138,7 @@
(LiteralsTest.hs:24:7,ITequal,[=]),
-(LiteralsTest.hs:24:9,ITinteger "1" 1,[1]),
+(LiteralsTest.hs:24:9,ITinteger (SourceText "1") 1,[1]),
(LiteralsTest.hs:25:1,ITvccurly,[]),
diff --git a/testsuite/tests/ghc-api/annotations-literals/parsed.hs b/testsuite/tests/ghc-api/annotations-literals/parsed.hs
index 8664fdcf13..0170bc2949 100644
--- a/testsuite/tests/ghc-api/annotations-literals/parsed.hs
+++ b/testsuite/tests/ghc-api/annotations-literals/parsed.hs
@@ -3,7 +3,7 @@
-- argument.
module Main where
--- import Data.Generics
+import BasicTypes
import Data.Data
import Data.List
import System.IO
@@ -42,21 +42,33 @@ testOneFile libdir fileName = do
gq ast = everything (++) ([] `mkQ` doHsLit `extQ` doOverLit) ast
doHsLit :: HsLit -> [String]
- doHsLit (HsChar src c) = ["HsChar [" ++ src ++ "] " ++ show c]
- doHsLit (HsCharPrim src c) = ["HsCharPrim [" ++ src ++ "] " ++ show c]
- doHsLit (HsString src c) = ["HsString [" ++ src ++ "] " ++ show c]
- doHsLit (HsStringPrim src c) = ["HsStringPrim [" ++ src ++ "] " ++ show c]
- doHsLit (HsInt src c) = ["HsInt [" ++ src ++ "] " ++ show c]
- doHsLit (HsIntPrim src c) = ["HsIntPrim [" ++ src ++ "] " ++ show c]
- doHsLit (HsWordPrim src c) = ["HsWordPrim [" ++ src ++ "] " ++ show c]
- doHsLit (HsInt64Prim src c) = ["HsInt64Prim [" ++ src ++ "] " ++ show c]
- doHsLit (HsWord64Prim src c) = ["HsWord64Prim [" ++ src ++ "] " ++ show c]
- doHsLit (HsInteger src c _) = ["HsInteger [" ++ src ++ "] " ++ show c]
+ doHsLit (HsChar (SourceText src) c)
+ = ["HsChar [" ++ src ++ "] " ++ show c]
+ doHsLit (HsCharPrim (SourceText src) c)
+ = ["HsCharPrim [" ++ src ++ "] " ++ show c]
+ doHsLit (HsString (SourceText src) c)
+ = ["HsString [" ++ src ++ "] " ++ show c]
+ doHsLit (HsStringPrim (SourceText src) c)
+ = ["HsStringPrim [" ++ src ++ "] " ++ show c]
+ doHsLit (HsInt (SourceText src) c)
+ = ["HsInt [" ++ src ++ "] " ++ show c]
+ doHsLit (HsIntPrim (SourceText src) c)
+ = ["HsIntPrim [" ++ src ++ "] " ++ show c]
+ doHsLit (HsWordPrim (SourceText src) c)
+ = ["HsWordPrim [" ++ src ++ "] " ++ show c]
+ doHsLit (HsInt64Prim (SourceText src) c)
+ = ["HsInt64Prim [" ++ src ++ "] " ++ show c]
+ doHsLit (HsWord64Prim (SourceText src) c)
+ = ["HsWord64Prim [" ++ src ++ "] " ++ show c]
+ doHsLit (HsInteger (SourceText src) c _)
+ = ["HsInteger [" ++ src ++ "] " ++ show c]
doHsLit _ = []
doOverLit :: OverLitVal -> [String]
- doOverLit (HsIntegral src c) = ["HsIntegral [" ++ src ++ "] " ++ show c]
- doOverLit (HsIsString src c) = ["HsIsString [" ++ src ++ "] " ++ show c]
+ doOverLit (HsIntegral (SourceText src) c)
+ = ["HsIntegral [" ++ src ++ "] " ++ show c]
+ doOverLit (HsIsString (SourceText src) c)
+ = ["HsIsString [" ++ src ++ "] " ++ show c]
doOverLit _ = []
pp a = showPpr unsafeGlobalDynFlags a
diff --git a/testsuite/tests/ghc-api/annotations-literals/parsed.stdout b/testsuite/tests/ghc-api/annotations-literals/parsed.stdout
index ce7a004929..7984181504 100644
--- a/testsuite/tests/ghc-api/annotations-literals/parsed.stdout
+++ b/testsuite/tests/ghc-api/annotations-literals/parsed.stdout
@@ -1,12 +1,12 @@
HsIntegral [0003] 3
-HsString [] "noExpr"
+HsString [noExpr] "noExpr"
HsIntegral [0x04] 4
-HsString [] "noExpr"
+HsString [noExpr] "noExpr"
HsString ["\x20"] " "
HsChar ['\x20'] ' '
-HsString [] "noExpr"
+HsString [noExpr] "noExpr"
HsCharPrim ['\x41'] 'A'
HsIntPrim [0004#] 4
HsWordPrim [005##] 5
HsIntegral [1] 1
-HsString [] "noExpr"
+HsString [noExpr] "noExpr"