[commit: testsuite] master: Add test case for #7014. (9925b8c)

Paolo Capriotti p.capriotti at gmail.com
Sat Jul 28 00:09:46 CEST 2012


Repository : ssh://darcs.haskell.org//srv/darcs/testsuite

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/9925b8c79c7aadf6bc47f7735d5c2653929c50f2

>---------------------------------------------------------------

commit 9925b8c79c7aadf6bc47f7735d5c2653929c50f2
Author: Paolo Capriotti <p.capriotti at gmail.com>
Date:   Fri Jul 6 16:57:43 2012 +0100

    Add test case for #7014.

>---------------------------------------------------------------

 tests/numeric/should_run/Makefile      |    7 +++
 tests/numeric/should_run/T7014.hs      |   91 ++++++++++++++++++++++++++++++++
 tests/numeric/should_run/T7014.primops |   12 ++++
 tests/numeric/should_run/T7014.stdout  |   21 +++++++
 tests/numeric/should_run/all.T         |    4 ++
 5 files changed, 135 insertions(+), 0 deletions(-)

diff --git a/tests/numeric/should_run/Makefile b/tests/numeric/should_run/Makefile
index 9101fbd..26ec990 100644
--- a/tests/numeric/should_run/Makefile
+++ b/tests/numeric/should_run/Makefile
@@ -1,3 +1,10 @@
 TOP=../../..
 include $(TOP)/mk/boilerplate.mk
 include $(TOP)/mk/test.mk
+
+.PHONY: T7014
+T7014:
+	rm -f T7014.simpl T7014.o T7014.hi
+	'$(TEST_HC)' -Wall -v0 -O --make T7014.hs -fforce-recomp -ddump-simpl > T7014.simpl
+	! grep -q -f T7014.primops T7014.simpl
+	./T7014
diff --git a/tests/numeric/should_run/T7014.hs b/tests/numeric/should_run/T7014.hs
new file mode 100644
index 0000000..8237538
--- /dev/null
+++ b/tests/numeric/should_run/T7014.hs
@@ -0,0 +1,91 @@
+module Main where
+
+import Data.Bits
+import Data.Word
+
+test_and1 :: Word -> Word
+test_and1 x = x .&. 0
+
+test_and2 :: Word -> Word
+test_and2 x = 0 .&. x
+
+test_or1 :: Word -> Word
+test_or1 x = x .|. 0
+
+test_or2 :: Word -> Word
+test_or2 x = 0 .|. x
+
+test_shiftL :: Word -> Word
+test_shiftL x = shiftL x 0
+
+test_shiftR :: Word -> Word
+test_shiftR x = shiftR x 0
+
+test_add1 :: Int -> Int
+test_add1 x = x + 0
+
+test_add2 :: Int -> Int
+test_add2 x = 0 + x
+
+test_sub1 :: Int -> Int
+test_sub1 x = x - 0
+
+test_sub2 :: Int -> Int
+test_sub2 x = x - x
+
+test_mul1 :: Int -> Int
+test_mul1 x = x * 1
+
+test_mul2 :: Int -> Int
+test_mul2 x = 1 * x
+
+test_mul3 :: Int -> Int
+test_mul3 x = x * 0
+
+test_quot :: Int -> Int
+test_quot x = x `quot` 1
+
+test_rem :: Int -> Int
+test_rem x = x `rem` 1
+
+test_addf1 :: Float -> Float
+test_addf1 x = x + 0
+
+test_addf2 :: Float -> Float
+test_addf2 x = 0 + x
+
+test_subf :: Float -> Float
+test_subf x = x - 0
+
+test_mulf1 :: Float -> Float
+test_mulf1 x = x * 1
+
+test_mulf2 :: Float -> Float
+test_mulf2 x = 1 * x
+
+test_divf :: Float -> Float
+test_divf x = x / 1
+
+main :: IO ()
+main = do
+  print $ test_and1 42
+  print $ test_and2 43
+  print $ test_or1 44
+  print $ test_or2 45
+  print $ test_shiftL 46
+  print $ test_shiftR 47
+  print $ test_add1 48
+  print $ test_add2 49
+  print $ test_sub1 50
+  print $ test_sub2 51
+  print $ test_mul1 52
+  print $ test_mul2 53
+  print $ test_mul3 54
+  print $ test_quot 55
+  print $ test_rem 56
+  print $ test_addf1 57
+  print $ test_addf2 58
+  print $ test_subf 59
+  print $ test_mulf1 60
+  print $ test_mulf2 61
+  print $ test_divf 62
diff --git a/tests/numeric/should_run/T7014.primops b/tests/numeric/should_run/T7014.primops
new file mode 100644
index 0000000..3243666
--- /dev/null
+++ b/tests/numeric/should_run/T7014.primops
@@ -0,0 +1,12 @@
+and#
+or#
+uncheckedShift.*#
+\+#
+\-#
+\*#
+quotInt#
+remInt#
+plusFloat#
+minusFloat#
+timesFloat#
+divideFloat#
diff --git a/tests/numeric/should_run/T7014.stdout b/tests/numeric/should_run/T7014.stdout
new file mode 100644
index 0000000..749a8f6
--- /dev/null
+++ b/tests/numeric/should_run/T7014.stdout
@@ -0,0 +1,21 @@
+0
+0
+44
+45
+46
+47
+48
+49
+50
+0
+52
+53
+0
+55
+0
+57.0
+58.0
+59.0
+60.0
+61.0
+62.0
diff --git a/tests/numeric/should_run/all.T b/tests/numeric/should_run/all.T
index 3e12a88..9244ac7 100644
--- a/tests/numeric/should_run/all.T
+++ b/tests/numeric/should_run/all.T
@@ -59,3 +59,7 @@ test('mul2', normal, compile_and_run, ['-fobject-code'])
 test('quotRem2', normal, compile_and_run, ['-fobject-code'])
 test('T5863', normal, compile_and_run, [''])
 
+test('T7014',
+     extra_clean(['T7014.simpl']),
+     run_command,
+     ['$MAKE -s --no-print-directory T7014'])





More information about the Cvs-ghc mailing list