summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2021-07-19 11:54:14 +0100
committerMatthew Pickering <matthewtpickering@gmail.com>2021-07-22 21:41:39 +0100
commit8aec2cce57723be66620bdb882251ee8841f2965 (patch)
tree1124908c89d0761c63baeaf4eb676ade2a36ecc1
parent40e18b29b2bdf0771a0d31efdf6a5f69c229663f (diff)
downloadhaskell-8aec2cce57723be66620bdb882251ee8841f2965.tar.gz
Add test for t16981
-rw-r--r--testsuite/tests/codeGen/should_run/T16981.hs7
-rw-r--r--testsuite/tests/codeGen/should_run/T16981.stdout1
-rw-r--r--testsuite/tests/codeGen/should_run/T16981A.hs30
-rw-r--r--testsuite/tests/codeGen/should_run/all.T5
4 files changed, 43 insertions, 0 deletions
diff --git a/testsuite/tests/codeGen/should_run/T16981.hs b/testsuite/tests/codeGen/should_run/T16981.hs
new file mode 100644
index 0000000000..8f7dfb7825
--- /dev/null
+++ b/testsuite/tests/codeGen/should_run/T16981.hs
@@ -0,0 +1,7 @@
+module Main where
+
+import T16981A
+
+main :: IO ()
+main = print splitInjectedAsWindowed
+
diff --git a/testsuite/tests/codeGen/should_run/T16981.stdout b/testsuite/tests/codeGen/should_run/T16981.stdout
new file mode 100644
index 0000000000..d00491fd7e
--- /dev/null
+++ b/testsuite/tests/codeGen/should_run/T16981.stdout
@@ -0,0 +1 @@
+1
diff --git a/testsuite/tests/codeGen/should_run/T16981A.hs b/testsuite/tests/codeGen/should_run/T16981A.hs
new file mode 100644
index 0000000000..a61a42bd7d
--- /dev/null
+++ b/testsuite/tests/codeGen/should_run/T16981A.hs
@@ -0,0 +1,30 @@
+-- Lib.hs
+{-# LANGUAGE StaticPointers #-}
+
+module T16981A where
+
+import GHC.StaticPtr
+
+class UniqueHash a where
+ hash :: a -> String
+
+{-# NOINLINE unCacheable #-}
+unCacheable :: Cacheable a -> a
+unCacheable (CExplicit _ a) = a
+
+data Cacheable a = CExplicit String a
+
+instance UniqueHash (StaticPtr a) where
+ hash ptr = show $ staticKey ptr
+
+instance IsStatic Cacheable where
+ fromStaticPtr ptr = CExplicit h a where
+ h = hash ptr
+ a = deRefStaticPtr ptr
+
+k = static 1
+
+{-# NOINLINE splitInjectedAsWindowed #-}
+splitInjectedAsWindowed :: Int
+-- WindowedDataset
+splitInjectedAsWindowed = unCacheable $ k
diff --git a/testsuite/tests/codeGen/should_run/all.T b/testsuite/tests/codeGen/should_run/all.T
index 4ea31f9011..48ecbe5971 100644
--- a/testsuite/tests/codeGen/should_run/all.T
+++ b/testsuite/tests/codeGen/should_run/all.T
@@ -216,3 +216,8 @@ test('CallConv', [when(unregisterised(), skip),
when(arch('x86_64'), extra_hc_opts('CallConv_x86_64.s')),
when(arch('aarch64'), extra_hc_opts('CallConv_aarch64.s'))],
compile_and_run, [''])
+
+test('T16981',
+ [ omit_ways(['ghci'])],
+ multimod_compile_and_run,
+ ['T16981', ''])