Add IntegerConversionRules
authorIan Lynagh <igloo@earth.li>
Wed, 27 Jun 2012 20:49:10 +0000 (21:49 +0100)
committerIan Lynagh <igloo@earth.li>
Wed, 27 Jun 2012 20:49:10 +0000 (21:49 +0100)
Includes a test for the problem in #6111.

testsuite/tests/lib/integer/IntegerConversionRules.hs [new file with mode: 0644]
testsuite/tests/lib/integer/Makefile
testsuite/tests/lib/integer/all.T

diff --git a/testsuite/tests/lib/integer/IntegerConversionRules.hs b/testsuite/tests/lib/integer/IntegerConversionRules.hs
new file mode 100644 (file)
index 0000000..cb5269f
--- /dev/null
@@ -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
+
index 227362d..34d5a17 100644 (file)
@@ -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"
+
index 8b27753..99056d6 100644 (file)
@@ -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'])