diff options
author | Ben Gamari <ben@smart-cactus.org> | 2022-06-22 18:07:31 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2022-06-23 17:26:48 -0400 |
commit | 5e4ba1f8d670b98df7e1dbdbeebb4ac078449066 (patch) | |
tree | 60c7d5f563079878ee177d878318c8a2d76a900b | |
parent | 9ebed0abdf858d2a6f916e384a9cb63d26665d47 (diff) | |
download | haskell-wip/T20735.tar.gz |
testsuite: Add test for #20735wip/T20735
4 files changed, 64 insertions, 0 deletions
diff --git a/testsuite/tests/codeGen/should_run/T20735/T20735.hs b/testsuite/tests/codeGen/should_run/T20735/T20735.hs new file mode 100644 index 0000000000..6d691bd41f --- /dev/null +++ b/testsuite/tests/codeGen/should_run/T20735/T20735.hs @@ -0,0 +1,19 @@ +{-# LANGUAGE ForeignFunctionInterface #-} + +module Main (main) where + +import Data.Int +import System.IO + +foreign import ccall "func64" func64 :: Int64 -> IO Int64 +foreign import ccall "func32" func32 :: Int32 -> IO Int32 +foreign import ccall "func16" func16 :: Int16 -> IO Int16 +foreign import ccall "func8" func8 :: Int8 -> IO Int8 + +main :: IO () +main = do + func64 (-2) >>= print >> hFlush stdout + func32 (-2) >>= print >> hFlush stdout + func16 (-2) >>= print >> hFlush stdout + func8 (-2) >>= print >> hFlush stdout + diff --git a/testsuite/tests/codeGen/should_run/T20735/T20735.stdout b/testsuite/tests/codeGen/should_run/T20735/T20735.stdout new file mode 100644 index 0000000000..218272cb82 --- /dev/null +++ b/testsuite/tests/codeGen/should_run/T20735/T20735.stdout @@ -0,0 +1,8 @@ +-2 +-1 +-2 +-1 +-2 +-1 +-2 +-1 diff --git a/testsuite/tests/codeGen/should_run/T20735/T20735_c.c b/testsuite/tests/codeGen/should_run/T20735/T20735_c.c new file mode 100644 index 0000000000..890d09199a --- /dev/null +++ b/testsuite/tests/codeGen/should_run/T20735/T20735_c.c @@ -0,0 +1,32 @@ +#include <stdio.h> +#include <stdint.h> + + +int64_t func64(int64_t targetType) +{ + printf("%d\n", (int)targetType); + fflush(stdout); + return (-1); +} + +int32_t func32(int32_t targetType) +{ + printf("%d\n", (int)targetType); + fflush(stdout); + return (-1); +} + +int16_t func16(int16_t targetType) +{ + printf("%d\n", (int)targetType); + fflush(stdout); + return (-1); +} + +int8_t func8(int8_t targetType) +{ + printf("%d\n", (int)targetType); + fflush(stdout); + return (-1); +} + diff --git a/testsuite/tests/codeGen/should_run/T20735/all.T b/testsuite/tests/codeGen/should_run/T20735/all.T new file mode 100644 index 0000000000..d10c0c0f79 --- /dev/null +++ b/testsuite/tests/codeGen/should_run/T20735/all.T @@ -0,0 +1,5 @@ +test('T20735', + normal, + multi_compile_and_run, + ['T20735', [('T20735_c.c', '')], '']) + |