Commit f6282fe0 authored by simonmar's avatar simonmar

[project @ 2003-10-01 09:11:36 by simonmar]

Add test for returning a Bool from a foreign export.
parent ca6b9b66
......@@ -42,3 +42,5 @@ test('ffi009', expect_fail_for(['optasm','extcore', 'optextcore']), compile_and_
# Doesn't work with External Core due to __labels
test('ffi010', expect_fail_for(['extcore','optextcore']), compile_and_run, [''])
test('ffi011', normal, compile_and_run, [''])
{-# OPTIONS -fffi #-}
-- !!! returning a Bool from a foreign export confused GHCi 6.0.1.
import Foreign
foreign import ccall "wrapper"
mkFoo :: (Int -> IO Bool) -> IO (FunPtr (Int -> IO Bool))
foo :: Int -> IO Bool
foo x = return (x == 42)
foreign import ccall "dynamic"
call_foo :: FunPtr (Int -> IO Bool) -> Int -> IO Bool
main = do
foo_fun <- mkFoo foo
call_foo foo_fun 3 >>= print
call_foo foo_fun 42 >>= print
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment