summaryrefslogtreecommitdiff
path: root/testsuite/tests/printer
diff options
context:
space:
mode:
authorAlan Zimmerman <alan.zimm@gmail.com>2021-08-22 09:13:30 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-09-08 16:58:51 -0400
commit86e5a6c34128a20d04808fcffcc49623a5d967bf (patch)
tree1d98c5a6049c707c66ab2b9c3247697d4578b4a8 /testsuite/tests/printer
parent9fc0fe008c13782cb7b1962b0ebed0bb09ecfb6f (diff)
downloadhaskell-86e5a6c34128a20d04808fcffcc49623a5d967bf.tar.gz
EPA: Capture '+' location for NPlusKPat
The location of the plus symbol was being discarded, we now capture it. Closes #20243
Diffstat (limited to 'testsuite/tests/printer')
-rw-r--r--testsuite/tests/printer/Makefile6
-rw-r--r--testsuite/tests/printer/Test20243.hs42
-rw-r--r--testsuite/tests/printer/all.T1
3 files changed, 49 insertions, 0 deletions
diff --git a/testsuite/tests/printer/Makefile b/testsuite/tests/printer/Makefile
index 4d2dad7b86..ef8aa2858a 100644
--- a/testsuite/tests/printer/Makefile
+++ b/testsuite/tests/printer/Makefile
@@ -729,6 +729,12 @@ PprCommentPlacement2:
$(CHECK_PPR) $(LIBDIR) PprCommentPlacement2.hs
$(CHECK_EXACT) $(LIBDIR) PprCommentPlacement2.hs
+
+.PHONY: Test20243
+Test20243:
+ $(CHECK_PPR) $(LIBDIR) Test20243.hs
+ $(CHECK_EXACT) $(LIBDIR) Test20243.hs
+
.PHONY: Test20258
Test20258:
$(CHECK_PPR) $(LIBDIR) Test20258.hs
diff --git a/testsuite/tests/printer/Test20243.hs b/testsuite/tests/printer/Test20243.hs
new file mode 100644
index 0000000000..b78591f42d
--- /dev/null
+++ b/testsuite/tests/printer/Test20243.hs
@@ -0,0 +1,42 @@
+{-# LANGUAGE NPlusKPatterns #-}
+module Test20243 where
+
+singleline :: Integer -> Integer
+singleline (n + 1) = n
+
+multiline :: Integer -> Integer
+multiline(n
+ + 1) = n
+
+m :: Integer
+(m + 1) = 3
+
+erroR :: Int
+erroR = n where
+ (n+1,_) = (5,2)
+
+g :: Int -> Int
+g (x+1) = x
+g y = y
+g _ = 0 -- Overlapped
+
+h :: Int -> Int
+h (x+1) = x
+h _ = 0 -- Not overlapped
+
+kh (n+2) x | x > n = x * 2
+kh (x+1) (m+1) = m
+
+takeList :: Int -> [a] -> [a]
+takeList 0 _ = []
+takeList (n+1) [] = []
+takeList (n+1) (x:xs) = x : takeList n xs
+
+(^^^^) :: (Num a, Integral b) => a -> b -> a
+x ^^^^ 0 = 1
+x ^^^^ (n+1) = f x n x
+ where f _ 0 y = y
+ f x n y = g x n where
+ g x n | even n = g (x*x) (n `quot` 2)
+ | otherwise = f x (n-1) (x*y)
+_ ^^^^ _ = error "(^^^^){prelude}: negative exponent"
diff --git a/testsuite/tests/printer/all.T b/testsuite/tests/printer/all.T
index 4b9c04c01c..380e71c723 100644
--- a/testsuite/tests/printer/all.T
+++ b/testsuite/tests/printer/all.T
@@ -170,4 +170,5 @@ test('PprBracesSemiDataDecl', ignore_stderr, makefile_test, ['PprBracesSemiDataD
test('PprUnicodeSyntax', ignore_stderr, makefile_test, ['PprUnicodeSyntax'])
test('PprCommentPlacement2', ignore_stderr, makefile_test, ['PprCommentPlacement2'])
+test('Test20243', ignore_stderr, makefile_test, ['Test20243'])
test('Test20258', ignore_stderr, makefile_test, ['Test20258'])