summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <bgamari.foss@gmail.com>2017-09-01 10:52:47 -0400
committerBen Gamari <ben@smart-cactus.org>2017-09-01 10:58:11 -0400
commit8a1de424143f5b75e12976ca739e58fe04ae04d6 (patch)
tree0c129b8566a59e1bea21cf99f177be469c6040cb
parent1f052c50c1bcdfb838774eba5a83ae95a54f4702 (diff)
downloadhaskell-8a1de424143f5b75e12976ca739e58fe04ae04d6.tar.gz
Add testcase for #14178
Reviewers: austin Subscribers: rwbarton, thomie GHC Trac Issues: #14178 Differential Revision: https://phabricator.haskell.org/D3905
-rw-r--r--testsuite/tests/simplCore/should_run/T14178.hs33
-rw-r--r--testsuite/tests/simplCore/should_run/T14178.stdout2
-rw-r--r--testsuite/tests/simplCore/should_run/all.T1
3 files changed, 36 insertions, 0 deletions
diff --git a/testsuite/tests/simplCore/should_run/T14178.hs b/testsuite/tests/simplCore/should_run/T14178.hs
new file mode 100644
index 0000000000..ef76324994
--- /dev/null
+++ b/testsuite/tests/simplCore/should_run/T14178.hs
@@ -0,0 +1,33 @@
+import System.Exit
+import Control.Monad.Trans.State.Strict
+
+eval :: Int -> State Int a -> a
+eval p = fst . flip runState p
+
+advance :: Int -> State Int ()
+advance = modify' . (+)
+
+loc :: State Int Int
+loc = get
+
+emit1 :: State Int ()
+emit1 = advance 1
+
+emitN :: Int -> State Int ()
+-- adding in the 0 case, breaks with HEAD. 8.2.1 is fine with it.
+-- emitN 0 = advance 0
+emitN 0 = pure ()
+emitN n = advance n
+
+align8 :: State Int ()
+align8 = do
+ bits <- (`mod` 8) <$> loc
+ emitN (8 - bits)
+
+main :: IO ()
+main = do
+ let p = eval 0 (emit1 >> align8 >> loc)
+ putStrLn $ show p
+ if p == 8
+ then putStrLn "OK" >> exitSuccess
+ else putStrLn "FAIL" >> exitFailure
diff --git a/testsuite/tests/simplCore/should_run/T14178.stdout b/testsuite/tests/simplCore/should_run/T14178.stdout
new file mode 100644
index 0000000000..f91f66e37e
--- /dev/null
+++ b/testsuite/tests/simplCore/should_run/T14178.stdout
@@ -0,0 +1,2 @@
+8
+OK
diff --git a/testsuite/tests/simplCore/should_run/all.T b/testsuite/tests/simplCore/should_run/all.T
index 75ff431910..4ba5a71e94 100644
--- a/testsuite/tests/simplCore/should_run/all.T
+++ b/testsuite/tests/simplCore/should_run/all.T
@@ -77,3 +77,4 @@ test('T13733', expect_broken(13733), compile_and_run, [''])
test('T13429', normal, compile_and_run, [''])
test('T13429_2', normal, compile_and_run, [''])
test('T13750', normal, compile_and_run, [''])
+test('T14178', normal, compile_and_run, [''])