summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorAlan Zimmerman <alan.zimm@gmail.com>2022-05-21 18:53:24 +0100
committerMatthew Pickering <matthewtpickering@gmail.com>2022-05-30 18:10:14 +0100
commitc7cb05af66e61f53a59c400f402fc2309f75dc49 (patch)
treec490d48a925f223eda1144b97c6b4415a45e229a /testsuite
parent389759ce0b0da88e6918bb96da42e143eb0988a1 (diff)
downloadhaskell-c7cb05af66e61f53a59c400f402fc2309f75dc49.tar.gz
EPA: Comment Order Reversed
Make sure comments captured in the exact print annotations are in order of increasing location Closes #20718 (cherry picked from commit e2520df3fffa0cf22fb19c5fb872832d11c07d35)
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/tests/parser/should_compile/DumpParsedAstComments.stderr12
-rw-r--r--testsuite/tests/parser/should_compile/T20718.hs11
-rw-r--r--testsuite/tests/parser/should_compile/T20718.stderr162
-rw-r--r--testsuite/tests/parser/should_compile/T20718b.hs7
-rw-r--r--testsuite/tests/parser/should_compile/T20718b.stderr70
-rw-r--r--testsuite/tests/parser/should_compile/all.T3
6 files changed, 259 insertions, 6 deletions
diff --git a/testsuite/tests/parser/should_compile/DumpParsedAstComments.stderr b/testsuite/tests/parser/should_compile/DumpParsedAstComments.stderr
index 34d759a794..f25f99cd32 100644
--- a/testsuite/tests/parser/should_compile/DumpParsedAstComments.stderr
+++ b/testsuite/tests/parser/should_compile/DumpParsedAstComments.stderr
@@ -21,20 +21,20 @@
(EpaCommentsBalanced
[(L
(Anchor
- { DumpParsedAstComments.hs:(2,1)-(4,4) }
+ { DumpParsedAstComments.hs:1:1-28 }
(UnchangedAnchor))
(EpaComment
(EpaBlockComment
- "{-/n Block comment at the beginning/n -}")
- { DumpParsedAstComments.hs:1:1-28 }))
+ "{-# LANGUAGE Haskell2010 #-}")
+ { DumpParsedAstComments.hs:1:1 }))
,(L
(Anchor
- { DumpParsedAstComments.hs:1:1-28 }
+ { DumpParsedAstComments.hs:(2,1)-(4,4) }
(UnchangedAnchor))
(EpaComment
(EpaBlockComment
- "{-# LANGUAGE Haskell2010 #-}")
- { DumpParsedAstComments.hs:1:1 }))]
+ "{-/n Block comment at the beginning/n -}")
+ { DumpParsedAstComments.hs:1:1-28 }))]
[(L
(Anchor
{ DumpParsedAstComments.hs:13:1 }
diff --git a/testsuite/tests/parser/should_compile/T20718.hs b/testsuite/tests/parser/should_compile/T20718.hs
new file mode 100644
index 0000000000..0b1a3e6a0f
--- /dev/null
+++ b/testsuite/tests/parser/should_compile/T20718.hs
@@ -0,0 +1,11 @@
+-- top of file 1
+-- top of file 2
+module T20718 where
+
+-- before 1
+-- before 2
+
+x = 1
+
+-- end 1
+-- end 2
diff --git a/testsuite/tests/parser/should_compile/T20718.stderr b/testsuite/tests/parser/should_compile/T20718.stderr
new file mode 100644
index 0000000000..c041db260a
--- /dev/null
+++ b/testsuite/tests/parser/should_compile/T20718.stderr
@@ -0,0 +1,162 @@
+
+==================== Parser AST ====================
+
+(L
+ { T20718.hs:1:1 }
+ (HsModule
+ (EpAnn
+ (Anchor
+ { T20718.hs:1:1 }
+ (UnchangedAnchor))
+ (AnnsModule
+ [(AddEpAnn AnnModule (EpaSpan { T20718.hs:3:1-6 }))
+ ,(AddEpAnn AnnWhere (EpaSpan { T20718.hs:3:15-19 }))]
+ (AnnList
+ (Nothing)
+ (Nothing)
+ (Nothing)
+ []
+ []))
+ (EpaCommentsBalanced
+ [(L
+ (Anchor
+ { T20718.hs:1:1-16 }
+ (UnchangedAnchor))
+ (EpaComment
+ (EpaLineComment
+ "-- top of file 1")
+ { T20718.hs:1:1 }))
+ ,(L
+ (Anchor
+ { T20718.hs:2:1-16 }
+ (UnchangedAnchor))
+ (EpaComment
+ (EpaLineComment
+ "-- top of file 2")
+ { T20718.hs:1:1-16 }))
+ ,(L
+ (Anchor
+ { T20718.hs:5:1-11 }
+ (UnchangedAnchor))
+ (EpaComment
+ (EpaLineComment
+ "-- before 1")
+ { T20718.hs:3:15-19 }))
+ ,(L
+ (Anchor
+ { T20718.hs:6:1-11 }
+ (UnchangedAnchor))
+ (EpaComment
+ (EpaLineComment
+ "-- before 2")
+ { T20718.hs:5:1-11 }))]
+ [(L
+ (Anchor
+ { T20718.hs:12:1 }
+ (UnchangedAnchor))
+ (EpaComment
+ (EpaEofComment)
+ { T20718.hs:11:1-8 }))]))
+ (VirtualBraces
+ (1))
+ (Just
+ (L
+ (SrcSpanAnn (EpAnnNotUsed) { T20718.hs:3:8-13 })
+ {ModuleName: T20718}))
+ (Nothing)
+ []
+ [(L
+ (SrcSpanAnn (EpAnn
+ (Anchor
+ { T20718.hs:8:1-5 }
+ (UnchangedAnchor))
+ (AnnListItem
+ [])
+ (EpaComments
+ [(L
+ (Anchor
+ { T20718.hs:10:1-8 }
+ (UnchangedAnchor))
+ (EpaComment
+ (EpaLineComment
+ "-- end 1")
+ { T20718.hs:8:5 }))
+ ,(L
+ (Anchor
+ { T20718.hs:11:1-8 }
+ (UnchangedAnchor))
+ (EpaComment
+ (EpaLineComment
+ "-- end 2")
+ { T20718.hs:10:1-8 }))])) { T20718.hs:8:1-5 })
+ (ValD
+ (NoExtField)
+ (FunBind
+ (NoExtField)
+ (L
+ (SrcSpanAnn (EpAnnNotUsed) { T20718.hs:8:1 })
+ (Unqual
+ {OccName: x}))
+ (MG
+ (NoExtField)
+ (L
+ (SrcSpanAnn (EpAnnNotUsed) { T20718.hs:8:1-5 })
+ [(L
+ (SrcSpanAnn (EpAnnNotUsed) { T20718.hs:8:1-5 })
+ (Match
+ (EpAnn
+ (Anchor
+ { T20718.hs:8:1-5 }
+ (UnchangedAnchor))
+ []
+ (EpaComments
+ []))
+ (FunRhs
+ (L
+ (SrcSpanAnn (EpAnnNotUsed) { T20718.hs:8:1 })
+ (Unqual
+ {OccName: x}))
+ (Prefix)
+ (NoSrcStrict))
+ []
+ (GRHSs
+ (EpaComments
+ [])
+ [(L
+ (SrcSpanAnn
+ (EpAnnNotUsed)
+ { T20718.hs:8:3-5 })
+ (GRHS
+ (EpAnn
+ (Anchor
+ { T20718.hs:8:3-5 }
+ (UnchangedAnchor))
+ (GrhsAnn
+ (Nothing)
+ (AddEpAnn AnnEqual (EpaSpan { T20718.hs:8:3 })))
+ (EpaComments
+ []))
+ []
+ (L
+ (SrcSpanAnn (EpAnnNotUsed) { T20718.hs:8:5 })
+ (HsOverLit
+ (EpAnn
+ (Anchor
+ { T20718.hs:8:5 }
+ (UnchangedAnchor))
+ (NoEpAnns)
+ (EpaComments
+ []))
+ (OverLit
+ (NoExtField)
+ (HsIntegral
+ (IL
+ (SourceText 1)
+ (False)
+ (1))))))))]
+ (EmptyLocalBinds
+ (NoExtField)))))])
+ (FromSource))
+ [])))]
+ (Nothing)
+ (Nothing)))
diff --git a/testsuite/tests/parser/should_compile/T20718b.hs b/testsuite/tests/parser/should_compile/T20718b.hs
new file mode 100644
index 0000000000..9896dd933e
--- /dev/null
+++ b/testsuite/tests/parser/should_compile/T20718b.hs
@@ -0,0 +1,7 @@
+-- header comment 1
+-- header comment 2
+
+module T20718b where
+
+-- trailing comment 1
+-- trailing comment 2
diff --git a/testsuite/tests/parser/should_compile/T20718b.stderr b/testsuite/tests/parser/should_compile/T20718b.stderr
new file mode 100644
index 0000000000..d359e5c5cf
--- /dev/null
+++ b/testsuite/tests/parser/should_compile/T20718b.stderr
@@ -0,0 +1,70 @@
+
+==================== Parser AST ====================
+
+(L
+ { T20718b.hs:1:1 }
+ (HsModule
+ (EpAnn
+ (Anchor
+ { T20718b.hs:1:1 }
+ (UnchangedAnchor))
+ (AnnsModule
+ [(AddEpAnn AnnModule (EpaSpan { T20718b.hs:4:1-6 }))
+ ,(AddEpAnn AnnWhere (EpaSpan { T20718b.hs:4:16-20 }))]
+ (AnnList
+ (Nothing)
+ (Nothing)
+ (Nothing)
+ []
+ []))
+ (EpaCommentsBalanced
+ [(L
+ (Anchor
+ { T20718b.hs:1:1-19 }
+ (UnchangedAnchor))
+ (EpaComment
+ (EpaLineComment
+ "-- header comment 1")
+ { T20718b.hs:1:1 }))
+ ,(L
+ (Anchor
+ { T20718b.hs:2:1-19 }
+ (UnchangedAnchor))
+ (EpaComment
+ (EpaLineComment
+ "-- header comment 2")
+ { T20718b.hs:1:1-19 }))
+ ,(L
+ (Anchor
+ { T20718b.hs:6:1-21 }
+ (UnchangedAnchor))
+ (EpaComment
+ (EpaLineComment
+ "-- trailing comment 1")
+ { T20718b.hs:4:16-20 }))
+ ,(L
+ (Anchor
+ { T20718b.hs:7:1-21 }
+ (UnchangedAnchor))
+ (EpaComment
+ (EpaLineComment
+ "-- trailing comment 2")
+ { T20718b.hs:6:1-21 }))]
+ [(L
+ (Anchor
+ { T20718b.hs:8:1 }
+ (UnchangedAnchor))
+ (EpaComment
+ (EpaEofComment)
+ { T20718b.hs:7:1-21 }))]))
+ (VirtualBraces
+ (1))
+ (Just
+ (L
+ (SrcSpanAnn (EpAnnNotUsed) { T20718b.hs:4:8-14 })
+ {ModuleName: T20718b}))
+ (Nothing)
+ []
+ []
+ (Nothing)
+ (Nothing)))
diff --git a/testsuite/tests/parser/should_compile/all.T b/testsuite/tests/parser/should_compile/all.T
index e5116ffd02..ffadeeaf1c 100644
--- a/testsuite/tests/parser/should_compile/all.T
+++ b/testsuite/tests/parser/should_compile/all.T
@@ -188,3 +188,6 @@ test('T20551', normal, compile, [''])
test('OpaqueParseWarn1', normal, compile, [''])
test('T20385', normal, compile, [''])
test('T20385S', normal, compile, [''])
+
+test('T20718', normal, compile, ['-dsuppress-uniques -ddump-parsed-ast -dkeep-comments'])
+test('T20718b', normal, compile, ['-dsuppress-uniques -ddump-parsed-ast -dkeep-comments']) \ No newline at end of file