summaryrefslogtreecommitdiff
path: root/testsuite/tests/codeGen
diff options
context:
space:
mode:
authorARATA Mizuki <minorinoki@gmail.com>2022-03-17 21:42:23 +0900
committerMatthew Pickering <matthewtpickering@gmail.com>2022-04-01 11:02:35 +0100
commit5df9f5e732a1086c66ad391e581f55b9d3e3712c (patch)
treeab55513ded3b94c3b85c077d4ff46e8336a6b086 /testsuite/tests/codeGen
parent6f4dc372d5c91686ad4148b82ad49a71d4dd82b5 (diff)
downloadhaskell-5df9f5e732a1086c66ad391e581f55b9d3e3712c.tar.gz
Add test cases for #20640
Closes #20640
Diffstat (limited to 'testsuite/tests/codeGen')
-rw-r--r--testsuite/tests/codeGen/should_run/T20640a.hs9
-rw-r--r--testsuite/tests/codeGen/should_run/T20640a.stdout2
-rw-r--r--testsuite/tests/codeGen/should_run/T20640b.hs8
-rw-r--r--testsuite/tests/codeGen/should_run/T20640b.stdout1
-rw-r--r--testsuite/tests/codeGen/should_run/all.T2
5 files changed, 22 insertions, 0 deletions
diff --git a/testsuite/tests/codeGen/should_run/T20640a.hs b/testsuite/tests/codeGen/should_run/T20640a.hs
new file mode 100644
index 0000000000..2bece3699b
--- /dev/null
+++ b/testsuite/tests/codeGen/should_run/T20640a.hs
@@ -0,0 +1,9 @@
+import GHC.Foreign
+import GHC.IO.Encoding
+import qualified Foreign.C.String as F
+
+main = withCStringLen utf8 "\x1F424" $ \csl -> do
+ s <- F.peekCAStringLen csl
+ print s
+ s <- peekCStringLen utf8 csl
+ print s
diff --git a/testsuite/tests/codeGen/should_run/T20640a.stdout b/testsuite/tests/codeGen/should_run/T20640a.stdout
new file mode 100644
index 0000000000..9a4fb47620
--- /dev/null
+++ b/testsuite/tests/codeGen/should_run/T20640a.stdout
@@ -0,0 +1,2 @@
+"\240\159\144\164"
+"\128036"
diff --git a/testsuite/tests/codeGen/should_run/T20640b.hs b/testsuite/tests/codeGen/should_run/T20640b.hs
new file mode 100644
index 0000000000..367508b90d
--- /dev/null
+++ b/testsuite/tests/codeGen/should_run/T20640b.hs
@@ -0,0 +1,8 @@
+import Data.Word
+
+foo :: Word8 -> Char
+foo c | c <= 0xdf = 'A' -- 0xdf=223
+ | otherwise = 'B'
+{-# NOINLINE foo #-}
+
+main = print (foo 0xce) -- 0xce=206
diff --git a/testsuite/tests/codeGen/should_run/T20640b.stdout b/testsuite/tests/codeGen/should_run/T20640b.stdout
new file mode 100644
index 0000000000..30dfe4aef7
--- /dev/null
+++ b/testsuite/tests/codeGen/should_run/T20640b.stdout
@@ -0,0 +1 @@
+'A'
diff --git a/testsuite/tests/codeGen/should_run/all.T b/testsuite/tests/codeGen/should_run/all.T
index 88db0c6b14..654db78d43 100644
--- a/testsuite/tests/codeGen/should_run/all.T
+++ b/testsuite/tests/codeGen/should_run/all.T
@@ -217,3 +217,5 @@ test('CallConv', [when(unregisterised(), skip),
when(arch('aarch64'), extra_hc_opts('CallConv_aarch64.s'))],
compile_and_run, [''])
test('T21186', normal, compile_and_run, [''])
+test('T20640a', normal, compile_and_run, [''])
+test('T20640b', normal, compile_and_run, [''])