Add a couple of tests for gcdInteger
authorIan Lynagh <igloo@earth.li>
Fri, 13 Jul 2012 18:44:47 +0000 (19:44 +0100)
committerIan Lynagh <igloo@earth.li>
Fri, 13 Jul 2012 18:44:47 +0000 (19:44 +0100)
testsuite/tests/lib/integer/Makefile
testsuite/tests/lib/integer/T7041.hs [new file with mode: 0644]
testsuite/tests/lib/integer/all.T
testsuite/tests/lib/integer/gcdInteger.hs [new file with mode: 0644]
testsuite/tests/lib/integer/gcdInteger.stdout [new file with mode: 0644]

index 34d5a17..77b733d 100644 (file)
@@ -56,3 +56,9 @@ IntegerConversionRules:
        -grep -q integerToWord     $@.simpl && echo "integerToWord present"
        -grep -q int2Word          $@.simpl || echo "int2Word absent"
 
+.PHONY: T7041
+T7041:
+       '$(TEST_HC)' -Wall -v0 -O -c $@.hs -fforce-recomp -ddump-simpl > $@.simpl
+       -grep -q gcdInteger        $@.simpl && echo "gcdInteger present"
+       -grep -q "gcdInt\>"        $@.simpl || echo "gcdInt absent"
+
diff --git a/testsuite/tests/lib/integer/T7041.hs b/testsuite/tests/lib/integer/T7041.hs
new file mode 100644 (file)
index 0000000..02ef996
--- /dev/null
@@ -0,0 +1,6 @@
+
+module T7041 where
+
+gcdInt :: Int -> Int -> Int
+gcdInt a b = fromInteger (gcd (toInteger a) (toInteger b))
+
index 99056d6..cb57675 100644 (file)
@@ -12,4 +12,9 @@ test('IntegerConversionRules',
      extra_clean(['IntegerConversionRules.simpl']),
      run_command,
      ['$MAKE -s --no-print-directory IntegerConversionRules'])
+test('gcdInteger', normal, compile_and_run, [''])
+test('T7041',
+     extra_clean(['T7041.simpl']),
+     run_command,
+     ['$MAKE -s --no-print-directory T7041'])
 
diff --git a/testsuite/tests/lib/integer/gcdInteger.hs b/testsuite/tests/lib/integer/gcdInteger.hs
new file mode 100644 (file)
index 0000000..2e945a8
--- /dev/null
@@ -0,0 +1,17 @@
+
+{-# LANGUAGE MagicHash #-}
+
+module Main (main) where
+
+import GHC.Base
+import GHC.Integer
+
+main :: IO ()
+main = case i of
+       I# i# ->
+           print (gcd (smallInteger i#) (smallInteger i#))
+
+{-# NOINLINE i #-}
+i :: Int
+i = minBound
+
diff --git a/testsuite/tests/lib/integer/gcdInteger.stdout b/testsuite/tests/lib/integer/gcdInteger.stdout
new file mode 100644 (file)
index 0000000..b0898f3
--- /dev/null
@@ -0,0 +1 @@
+9223372036854775808