summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2021-08-04 12:14:39 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-10-22 19:20:05 -0400
commitfa5870d3ac0a64515d3e76af256e81b9dc8590bd (patch)
treeb5ad0be6aeeae694c4c8ad314d69fdf570cf7765 /testsuite
parent77c6f3e6be3b94c48ec6c9b7015dab69ae47564e (diff)
downloadhaskell-fa5870d3ac0a64515d3e76af256e81b9dc8590bd.tar.gz
Add test for #19641
Now that Bignum predicates are inlined (!6696), we only need to add a test. Fix #19641
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/tests/numeric/should_compile/T19641.hs11
-rw-r--r--testsuite/tests/numeric/should_compile/T19641.stderr32
-rw-r--r--testsuite/tests/numeric/should_compile/all.T1
3 files changed, 44 insertions, 0 deletions
diff --git a/testsuite/tests/numeric/should_compile/T19641.hs b/testsuite/tests/numeric/should_compile/T19641.hs
new file mode 100644
index 0000000000..826472d7a3
--- /dev/null
+++ b/testsuite/tests/numeric/should_compile/T19641.hs
@@ -0,0 +1,11 @@
+module Test where
+
+import Data.Bits
+import GHC.Num.Integer
+import GHC.Num.Natural
+
+integer_to_int :: Integer -> Maybe Int
+integer_to_int = toIntegralSized
+
+natural_to_word :: Natural -> Maybe Word
+natural_to_word = toIntegralSized
diff --git a/testsuite/tests/numeric/should_compile/T19641.stderr b/testsuite/tests/numeric/should_compile/T19641.stderr
new file mode 100644
index 0000000000..b79d0217ee
--- /dev/null
+++ b/testsuite/tests/numeric/should_compile/T19641.stderr
@@ -0,0 +1,32 @@
+
+==================== Tidy Core ====================
+Result size of Tidy Core
+ = {terms: 22, types: 20, coercions: 0, joins: 0/0}
+
+natural_to_word
+ = \ x ->
+ case x of {
+ NS x1 -> Just (W# x1);
+ NB ds -> Nothing
+ }
+
+integer_to_int
+ = \ x ->
+ case x of {
+ IS ipv -> Just (I# ipv);
+ IP x1 -> Nothing;
+ IN ds -> Nothing
+ }
+
+
+------ Local rules for imported ids --------
+"SPEC/Test toIntegralSized @Integer @Int"
+ forall $dIntegral $dIntegral1 $dBits $dBits1.
+ toIntegralSized $dIntegral $dIntegral1 $dBits $dBits1
+ = integer_to_int
+"SPEC/Test toIntegralSized @Natural @Word"
+ forall $dIntegral $dIntegral1 $dBits $dBits1.
+ toIntegralSized $dIntegral $dIntegral1 $dBits $dBits1
+ = natural_to_word
+
+
diff --git a/testsuite/tests/numeric/should_compile/all.T b/testsuite/tests/numeric/should_compile/all.T
index 087eb7b358..4bcccaa521 100644
--- a/testsuite/tests/numeric/should_compile/all.T
+++ b/testsuite/tests/numeric/should_compile/all.T
@@ -17,3 +17,4 @@ test('T20374', normal, compile, ['-ddump-simpl -O -dsuppress-all -dno-typeable-b
test('T19769', normal, compile, ['-ddump-simpl -O -dsuppress-all -dno-typeable-binds -dsuppress-uniques'])
test('T20347', normal, compile, ['-ddump-simpl -O -dsuppress-all -dno-typeable-binds -dsuppress-uniques'])
test('T20448', normal, compile, ['-ddump-simpl -O -dsuppress-all -dno-typeable-binds -dsuppress-uniques'])
+test('T19641', normal, compile, ['-ddump-simpl -O -dsuppress-all -dno-typeable-binds -dsuppress-uniques'])