summaryrefslogtreecommitdiff
path: root/testsuite/tests/lib
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2020-10-06 18:27:33 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-10-10 14:51:20 -0400
commit74ee1237bf243dd7d8b758a53695575c364c3088 (patch)
treebc105f075904878cd118694506c93fa351b9bc08 /testsuite/tests/lib
parent22f218b729a751bc5e5965624a716fc542f502a5 (diff)
downloadhaskell-74ee1237bf243dd7d8b758a53695575c364c3088.tar.gz
Bignum: fix bigNatCompareWord# bug (#18813)
Diffstat (limited to 'testsuite/tests/lib')
-rw-r--r--testsuite/tests/lib/integer/T18813.hs22
-rw-r--r--testsuite/tests/lib/integer/T18813.stdout4
-rw-r--r--testsuite/tests/lib/integer/all.T1
3 files changed, 27 insertions, 0 deletions
diff --git a/testsuite/tests/lib/integer/T18813.hs b/testsuite/tests/lib/integer/T18813.hs
new file mode 100644
index 0000000000..77f598fe7b
--- /dev/null
+++ b/testsuite/tests/lib/integer/T18813.hs
@@ -0,0 +1,22 @@
+{-# LANGUAGE BangPatterns #-}
+{-# LANGUAGE MagicHash #-}
+{-# LANGUAGE ScopedTypeVariables #-}
+{-# OPTIONS_GHC -O0 #-}
+
+import GHC.Exts
+import GHC.Num.BigNat (bigNatCompareWord#, bigNatFromWord#)
+import GHC.Num.Integer (integerGcd)
+
+main :: IO ()
+main = do
+ let
+ x = noinline (14205695611797621937 :: Integer)
+ y = noinline (2 :: Word)
+ print (integerGcd x (toInteger y))
+ print (toInteger (gcd (fromInteger x) y :: Word))
+
+ let
+ x@(W# x#) = 1 :: Word
+ !x' = bigNatFromWord# x#
+ print (bigNatCompareWord# x' x#)
+ print (compare x x)
diff --git a/testsuite/tests/lib/integer/T18813.stdout b/testsuite/tests/lib/integer/T18813.stdout
new file mode 100644
index 0000000000..2434292deb
--- /dev/null
+++ b/testsuite/tests/lib/integer/T18813.stdout
@@ -0,0 +1,4 @@
+1
+1
+EQ
+EQ
diff --git a/testsuite/tests/lib/integer/all.T b/testsuite/tests/lib/integer/all.T
index fc6b77f6fa..3f45423730 100644
--- a/testsuite/tests/lib/integer/all.T
+++ b/testsuite/tests/lib/integer/all.T
@@ -11,6 +11,7 @@ test('integerPowMod', [], compile_and_run, [''])
test('integerGcdExt', [], compile_and_run, [''])
test('integerRecipMod', [], compile_and_run, [''])
test('bignumMatch', [], compile, [''])
+test('T18813', [], compile_and_run, [''])
# skip ghci as it doesn't support unboxed tuples
test('integerImportExport', [omit_ways(['ghci'])], compile_and_run, [''])