diff options
author | Sylvain Henry <sylvain@haskus.fr> | 2020-10-06 18:27:33 +0200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2020-10-10 14:51:20 -0400 |
commit | 74ee1237bf243dd7d8b758a53695575c364c3088 (patch) | |
tree | bc105f075904878cd118694506c93fa351b9bc08 /testsuite/tests/lib | |
parent | 22f218b729a751bc5e5965624a716fc542f502a5 (diff) | |
download | haskell-74ee1237bf243dd7d8b758a53695575c364c3088.tar.gz |
Bignum: fix bigNatCompareWord# bug (#18813)
Diffstat (limited to 'testsuite/tests/lib')
-rw-r--r-- | testsuite/tests/lib/integer/T18813.hs | 22 | ||||
-rw-r--r-- | testsuite/tests/lib/integer/T18813.stdout | 4 | ||||
-rw-r--r-- | testsuite/tests/lib/integer/all.T | 1 |
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, ['']) |