summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2022-10-12 14:51:31 -0400
committerBen Gamari <ben@smart-cactus.org>2022-10-19 09:33:39 -0400
commitb450061786714821901e40d5828d4221d7f49f54 (patch)
treedcde718fbf38922d775a08e804c8b1b844d91b09
parent9a12e4961256f4c25201b8b8736ab4ef4ba0083e (diff)
downloadhaskell-b450061786714821901e40d5828d4221d7f49f54.tar.gz
testsuite: Add test for #22282
This will complement mpickering's more general port of foundation's numerical testsuite, providing a test for the specific case found in #22282. (cherry picked from commit 1004bff7fd017ba698795b82f76b63e742420d34)
-rw-r--r--testsuite/tests/numeric/should_run/T22282.hs3
-rw-r--r--testsuite/tests/numeric/should_run/T22282.stdout2
-rw-r--r--testsuite/tests/numeric/should_run/T22282A.hs18
-rw-r--r--testsuite/tests/numeric/should_run/all.T1
4 files changed, 24 insertions, 0 deletions
diff --git a/testsuite/tests/numeric/should_run/T22282.hs b/testsuite/tests/numeric/should_run/T22282.hs
new file mode 100644
index 0000000000..63b36bb8e6
--- /dev/null
+++ b/testsuite/tests/numeric/should_run/T22282.hs
@@ -0,0 +1,3 @@
+import T22282A
+
+main = print $ testF 217 161
diff --git a/testsuite/tests/numeric/should_run/T22282.stdout b/testsuite/tests/numeric/should_run/T22282.stdout
new file mode 100644
index 0000000000..a62fe1172c
--- /dev/null
+++ b/testsuite/tests/numeric/should_run/T22282.stdout
@@ -0,0 +1,2 @@
+217
+
diff --git a/testsuite/tests/numeric/should_run/T22282A.hs b/testsuite/tests/numeric/should_run/T22282A.hs
new file mode 100644
index 0000000000..087c87c32a
--- /dev/null
+++ b/testsuite/tests/numeric/should_run/T22282A.hs
@@ -0,0 +1,18 @@
+{-# OPTIONS_GHC -O1 #-}
+{-# LANGUAGE MagicHash #-}
+module T22282A where
+
+import Data.Word
+import GHC.Prim
+import GHC.Word
+
+wtestF :: GHC.Prim.Word8# -> GHC.Prim.Word8# -> GHC.Prim.Word8#
+wtestF a b = case word8ToWord# b of
+ 0## -> a
+ _ -> plusWord8# (timesWord8# (quotWord8# a b) b) (remWord8# a b)
+{-# NOINLINE wtestF #-}
+
+testF :: Word8 -> Word8 -> Word8
+testF (W8# a) (W8# b) = W8# (wtestF a b)
+{-# INLINE testF #-}
+
diff --git a/testsuite/tests/numeric/should_run/all.T b/testsuite/tests/numeric/should_run/all.T
index 68888545f8..5d5b1f32bf 100644
--- a/testsuite/tests/numeric/should_run/all.T
+++ b/testsuite/tests/numeric/should_run/all.T
@@ -78,3 +78,4 @@ test('T19931', normal, compile_and_run, ['-O2'])
test('IntegerToFloat', normal, compile_and_run, [''])
test('T20291', normal, compile_and_run, [''])
+test('T22282', normal, compile_and_run, [''])