summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lynagh <igloo@earth.li>2012-06-27 21:49:10 +0100
committerIan Lynagh <igloo@earth.li>2012-06-27 21:49:10 +0100
commit71bb78003d58b8b95abba85b505f1bc82a0311cc (patch)
tree36174b5f0cb7d79b93d2d1e5cd58dbd8b91c8dee
parenta6bacc3e13ac2238b2ed4d837d2ed36a21a1a6bd (diff)
downloadhaskell-71bb78003d58b8b95abba85b505f1bc82a0311cc.tar.gz
Add IntegerConversionRules
Includes a test for the problem in #6111.
-rw-r--r--testsuite/tests/lib/integer/IntegerConversionRules.hs20
-rw-r--r--testsuite/tests/lib/integer/Makefile11
-rw-r--r--testsuite/tests/lib/integer/all.T4
3 files changed, 35 insertions, 0 deletions
diff --git a/testsuite/tests/lib/integer/IntegerConversionRules.hs b/testsuite/tests/lib/integer/IntegerConversionRules.hs
new file mode 100644
index 0000000000..cb5269f360
--- /dev/null
+++ b/testsuite/tests/lib/integer/IntegerConversionRules.hs
@@ -0,0 +1,20 @@
+
+module IntegerConversionRules where
+
+import Data.Word
+
+f1 :: Int -> Double
+f1 = fi
+
+f2 :: Int -> Float
+f2 = fi
+
+f3 :: Int -> Int
+f3 = fi
+
+f4 :: Int -> Word
+f4 = fi
+
+fi :: (Integral a, Num b) => a -> b
+fi = fromIntegral
+
diff --git a/testsuite/tests/lib/integer/Makefile b/testsuite/tests/lib/integer/Makefile
index 227362d72c..34d5a177ba 100644
--- a/testsuite/tests/lib/integer/Makefile
+++ b/testsuite/tests/lib/integer/Makefile
@@ -45,3 +45,14 @@ fromToInteger:
-grep integerToWord fromToInteger.simpl
-grep wordToInteger fromToInteger.simpl
+.PHONY: IntegerConversionRules
+IntegerConversionRules:
+ '$(TEST_HC)' -Wall -v0 -O -c $@.hs -fforce-recomp -ddump-simpl > $@.simpl
+ -grep -q smallInteger $@.simpl && echo "smallInteger present"
+ -grep -q doubleFromInteger $@.simpl && echo "doubleFromInteger present"
+ -grep -q int2Double $@.simpl || echo "int2Double absent"
+ -grep -q floatFromInteger $@.simpl && echo "floatFromInteger present"
+ -grep -q int2Float $@.simpl || echo "int2Float absent"
+ -grep -q integerToWord $@.simpl && echo "integerToWord present"
+ -grep -q int2Word $@.simpl || echo "int2Word absent"
+
diff --git a/testsuite/tests/lib/integer/all.T b/testsuite/tests/lib/integer/all.T
index 8b2775342c..99056d6b14 100644
--- a/testsuite/tests/lib/integer/all.T
+++ b/testsuite/tests/lib/integer/all.T
@@ -8,4 +8,8 @@ test('fromToInteger',
extra_clean(['fromToInteger.simpl']),
run_command,
['$MAKE -s --no-print-directory fromToInteger'])
+test('IntegerConversionRules',
+ extra_clean(['IntegerConversionRules.simpl']),
+ run_command,
+ ['$MAKE -s --no-print-directory IntegerConversionRules'])