diff options
author | Ben Gamari <ben@smart-cactus.org> | 2022-06-22 18:07:31 -0400 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2022-06-28 03:24:24 -0400 |
commit | c006ac0d1454119f0b456a00ff2416831c955e99 (patch) | |
tree | 87c11b387078b30a0445a10a7a2b18f46acefd54 /testsuite/tests | |
parent | 696d64c347364ce75e23d37884ec0bd2543b0a6a (diff) | |
download | haskell-c006ac0d1454119f0b456a00ff2416831c955e99.tar.gz |
testsuite: Add test for #20735
Diffstat (limited to 'testsuite/tests')
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', '')], '']) + |