summaryrefslogtreecommitdiff
path: root/testsuite/tests/showIface
diff options
context:
space:
mode:
authorReid Barton <rwbarton@gmail.com>2017-02-11 19:20:08 -0500
committerBen Gamari <ben@smart-cactus.org>2017-02-11 19:20:16 -0500
commit17b1e0bae7c0d7b4d3f8e1847e919c0e882e55c6 (patch)
treeb026d3b9b062a9ca7818f6319ea77288980b5cc5 /testsuite/tests/showIface
parent7fac7cdce975620e04eccfc2751190063cf715a8 (diff)
downloadhaskell-17b1e0bae7c0d7b4d3f8e1847e919c0e882e55c6.tar.gz
Mark orphan instances and rules in --show-iface output
Test Plan: new test Orphans Reviewers: austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D3086
Diffstat (limited to 'testsuite/tests/showIface')
-rw-r--r--testsuite/tests/showIface/Makefile7
-rw-r--r--testsuite/tests/showIface/Orphans.hs26
-rw-r--r--testsuite/tests/showIface/Orphans.stdout6
-rw-r--r--testsuite/tests/showIface/all.T1
4 files changed, 40 insertions, 0 deletions
diff --git a/testsuite/tests/showIface/Makefile b/testsuite/tests/showIface/Makefile
new file mode 100644
index 0000000000..49b90342b3
--- /dev/null
+++ b/testsuite/tests/showIface/Makefile
@@ -0,0 +1,7 @@
+TOP=../..
+include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/test.mk
+
+Orphans:
+ '$(TEST_HC)' $(TEST_HC_OPTS) -c Orphans.hs
+ '$(TEST_HC)' $(TEST_HC_OPTS) --show-iface Orphans.hi | grep -E '^(instance |family instance |"myrule)' | grep -v 'family instance modules:'
diff --git a/testsuite/tests/showIface/Orphans.hs b/testsuite/tests/showIface/Orphans.hs
new file mode 100644
index 0000000000..f3b7b6adec
--- /dev/null
+++ b/testsuite/tests/showIface/Orphans.hs
@@ -0,0 +1,26 @@
+{-# LANGUAGE TypeFamilies #-}
+{-# OPTIONS_GHC -O -Wno-inline-rule-shadowing #-}
+-- Rules are ignored without -O
+
+module Orphans where
+
+import GHC.Exts (IsList(..))
+
+-- Some orphan things
+instance IsList Bool where
+ type Item Bool = Double
+ fromList = undefined
+ toList = undefined
+
+{-# RULES "myrule1" id id = id #-}
+
+-- And some non-orphan things
+data X = X [Int]
+instance IsList X where
+ type Item X = Int
+ fromList = undefined
+ toList = undefined
+
+f :: X -> X
+f x = x
+{-# RULES "myrule2" id f = f #-}
diff --git a/testsuite/tests/showIface/Orphans.stdout b/testsuite/tests/showIface/Orphans.stdout
new file mode 100644
index 0000000000..d61a5c98f3
--- /dev/null
+++ b/testsuite/tests/showIface/Orphans.stdout
@@ -0,0 +1,6 @@
+instance [orphan] IsList [Bool] = $fIsListBool
+instance IsList [X] = $fIsListX
+family instance Item [X] = D:R:ItemX
+family instance [orphan] Item [Bool] = D:R:ItemBool
+"myrule1" [orphan] forall @ a id @ (a -> a) (id @ a) = id @ a
+"myrule2" forall id @ (X -> X) f = f
diff --git a/testsuite/tests/showIface/all.T b/testsuite/tests/showIface/all.T
new file mode 100644
index 0000000000..5c89b70b59
--- /dev/null
+++ b/testsuite/tests/showIface/all.T
@@ -0,0 +1 @@
+test('Orphans', normal, run_command, ['$MAKE -s --no-print-directory Orphans'])