Add a test for the integerToInt/smallInteger rule
authorIan Lynagh <igloo@earth.li>
Thu, 26 Jan 2012 13:45:03 +0000 (13:45 +0000)
committerIan Lynagh <igloo@earth.li>
Thu, 26 Jan 2012 14:55:31 +0000 (14:55 +0000)
testsuite/tests/lib/integer/Makefile
testsuite/tests/lib/integer/all.T
testsuite/tests/lib/integer/integerToInt_smallInteger.hs [new file with mode: 0644]

index 5199157..71a34a3 100644 (file)
@@ -36,3 +36,10 @@ integerConstantFolding:
        $(call CHECK,\<400280.0\>,encodeIntegerFloat)
        ./integerConstantFolding
 
+.PHONY: integerToInt_smallInteger
+integerToInt_smallInteger:
+       '$(TEST_HC)' -Wall -v0 -O -c integerToInt_smallInteger.hs -fforce-recomp -ddump-simpl > integerToInt_smallInteger.simpl
+# Rules should eliminate both functions
+       -grep integerToInt integerToInt_smallInteger.simpl
+       -grep smallInteger integerToInt_smallInteger.simpl
+
index ecff8fb..54782c0 100644 (file)
@@ -4,4 +4,8 @@ test('integerConstantFolding',
      extra_clean(['integerConstantFolding.simpl']),
      run_command,
      ['$MAKE -s --no-print-directory integerConstantFolding'])
+test('integerToInt_smallInteger',
+     extra_clean(['integerToInt_smallInteger.simpl']),
+     run_command,
+     ['$MAKE -s --no-print-directory integerToInt_smallInteger'])
 
diff --git a/testsuite/tests/lib/integer/integerToInt_smallInteger.hs b/testsuite/tests/lib/integer/integerToInt_smallInteger.hs
new file mode 100644 (file)
index 0000000..e084e05
--- /dev/null
@@ -0,0 +1,11 @@
+
+{-# LANGUAGE MagicHash #-}
+
+module Q where
+
+import GHC.Exts
+import GHC.Integer
+
+v :: Int
+v = I# (integerToInt (smallInteger 3#))
+