diff options
author | Ben Gamari <ben@smart-cactus.org> | 2022-06-22 18:07:31 -0400 |
---|---|---|
committer | Matthew Pickering <matthewtpickering@gmail.com> | 2022-07-05 11:14:19 +0100 |
commit | 038cc8564644e8f4fd1ad6b2ea5378d8c6c74133 (patch) | |
tree | 2e05c3dc006821129e2bd86480e08336e7892ce9 /testsuite | |
parent | 401d983beebed72cd43c5597b5d1bc52979feb46 (diff) | |
download | haskell-038cc8564644e8f4fd1ad6b2ea5378d8c6c74133.tar.gz |
testsuite: Add test for #20735
(cherry picked from commit c006ac0d1454119f0b456a00ff2416831c955e99)
Diffstat (limited to 'testsuite')
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', '')], '']) + |