summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2022-10-12 14:51:31 -0400
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-10-14 18:29:57 -0400
commit8eff62a43cebbb21f00aeea138bcc343d8ac8f34 (patch)
tree110c8b1938afbb2bd5026de5d82a2ab935389d58
parentee0deb8054da2a597fc5624469b4c44fd769ada2 (diff)
downloadhaskell-8eff62a43cebbb21f00aeea138bcc343d8ac8f34.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.
-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, [''])