Skip to content

Commit a9dd9b4

Browse files
aherrmannmergify-bot
authored andcommitted
Regression test: TH with cbits
1 parent 9c25977 commit a9dd9b4

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
load(
2+
"@rules_haskell//haskell:defs.bzl",
3+
"haskell_test",
4+
)
5+
6+
package(default_testonly = 1)
7+
8+
haskell_test(
9+
name = "template-haskell-with-cbits",
10+
srcs = [
11+
"Main.hs",
12+
"TH.hs",
13+
],
14+
deps = [
15+
"//tests/data:ourclibrary",
16+
"//tests/hackage:base",
17+
"//tests/hackage:template-haskell",
18+
],
19+
)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{-# LANGUAGE TemplateHaskell #-}
2+
3+
module Main where
4+
5+
import Control.Monad (unless)
6+
import System.Exit (exitFailure)
7+
import System.IO (hPutStrLn, stderr)
8+
import TH (value)
9+
10+
main :: IO ()
11+
main =
12+
unless ($(value) == 42) $ do
13+
hPutStrLn stderr "Expected 42"
14+
exitFailure
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{-# LANGUAGE TemplateHaskell #-}
2+
3+
module TH where
4+
5+
import Language.Haskell.TH
6+
7+
foreign import ccall "c_add_one" c_add_one' :: Int -> Int
8+
9+
value :: Q Exp
10+
value = [| c_add_one' 41 |]

0 commit comments

Comments
 (0)