testsuite: Add testcase for #13587
authorBen Gamari <bgamari.foss@gmail.com>
Sun, 23 Apr 2017 14:04:03 +0000 (10:04 -0400)
committerBen Gamari <ben@smart-cactus.org>
Sun, 23 Apr 2017 15:05:48 +0000 (11:05 -0400)
Test Plan: Validate

Reviewers: austin

Subscribers: rwbarton, thomie

GHC Trac Issues: #13587

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

testsuite/tests/th/T13587.hs [new file with mode: 0644]
testsuite/tests/th/T13587A.hs [new file with mode: 0644]
testsuite/tests/th/all.T

diff --git a/testsuite/tests/th/T13587.hs b/testsuite/tests/th/T13587.hs
new file mode 100644 (file)
index 0000000..2986fd2
--- /dev/null
@@ -0,0 +1,12 @@
+{-# LANGUAGE TemplateHaskell #-}
+
+import T13587A
+
+main :: IO ()
+main = do
+    let sin' = $$(importDoubleToDouble "sin")
+        cos' = $$(importDoubleToDouble "cos")
+    --
+    print (sin' 0)
+    print (cos' pi)
+
diff --git a/testsuite/tests/th/T13587A.hs b/testsuite/tests/th/T13587A.hs
new file mode 100644 (file)
index 0000000..b144cc2
--- /dev/null
@@ -0,0 +1,14 @@
+{-# LANGUAGE TemplateHaskell #-}
+{-# LANGUAGE QuasiQuotes     #-}
+
+module T13587A where
+
+import Language.Haskell.TH
+import Language.Haskell.TH.Syntax
+
+importDoubleToDouble :: String -> Q (TExp (Double -> Double))
+importDoubleToDouble fname = do
+    n <- newName fname
+    d <- forImpD CCall unsafe fname n [t|Double -> Double|]
+    addTopDecls [d]
+    unsafeTExpCoerce (varE n)
index e4d4731..7c98d13 100644 (file)
@@ -381,3 +381,4 @@ test('T13123', normal, compile, ['-v0'])
 test('T13098', normal, compile, ['-v0'])
 test('T11046', normal, multimod_compile, ['T11046','-v0'])
 test('T13366', normal, compile_and_run, ['-lstdc++ -v0'])
+test('T13587', expect_broken(13587), compile_and_run, ['-v0'])