Add a test for #11272
authorDavid Feuer <david.feuer@gmail.com>
Sat, 13 May 2017 20:09:31 +0000 (16:09 -0400)
committerDavid Feuer <David.Feuer@gmail.com>
Sat, 13 May 2017 20:09:32 +0000 (16:09 -0400)
Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #11272

Differential Revision: https://phabricator.haskell.org/D3561

testsuite/tests/simplCore/should_compile/Makefile
testsuite/tests/simplCore/should_compile/T11272.hs [new file with mode: 0644]
testsuite/tests/simplCore/should_compile/T11272a.hs [new file with mode: 0644]
testsuite/tests/simplCore/should_compile/all.T

index 779e7f2..a01edb2 100644 (file)
@@ -218,3 +218,10 @@ str-rules:
 .PHONY: T13340
 T13340:
        '$(TEST_HC)' $(TEST_HC_OPTS) -c -O T13340.hs -ddump-simpl -dsuppress-all | grep -c '\+#'
+
+
+# We expect to see all dictionaries specialized away.
+.PHONY: T11272
+T11272:
+       '$(TEST_HC)' $(TEST_HC_OPTS) -c -O T11272a.hs
+       '$(TEST_HC)' $(TEST_HC_OPTS) -c -O -ddump-prep T11272.hs | { ! grep Ord ;}
diff --git a/testsuite/tests/simplCore/should_compile/T11272.hs b/testsuite/tests/simplCore/should_compile/T11272.hs
new file mode 100644 (file)
index 0000000..d78ee15
--- /dev/null
@@ -0,0 +1,7 @@
+module T11272 where
+
+import T11272a as A
+import Control.Monad.Trans.State
+
+specialised :: Int -> Int -> ()
+specialised x y = execState (A.overloaded x y) ()
diff --git a/testsuite/tests/simplCore/should_compile/T11272a.hs b/testsuite/tests/simplCore/should_compile/T11272a.hs
new file mode 100644 (file)
index 0000000..19c9cd2
--- /dev/null
@@ -0,0 +1,10 @@
+module T11272a where
+
+import Control.Monad.Trans.State
+import Control.Monad
+
+overloaded :: Ord a => a -> a -> State () ()
+overloaded x y = do
+  () <- get
+  when (x <= y) (overloaded y x)
+{-# INLINABLE overloaded #-}
index 1b45930..1af5cbe 100644 (file)
@@ -260,3 +260,7 @@ test('T13468',
      run_command,
      ['$MAKE -s --no-print-directory T13468'])
 test('T13543', normal, compile, ['-ddump-str-signatures'])
+test('T11272',
+     normal,
+     run_command,
+     ['$MAKE -s --no-print-directory T11272'])