summaryrefslogtreecommitdiff
path: root/testsuite/tests/numeric
diff options
context:
space:
mode:
authorPaolo Capriotti <p.capriotti@gmail.com>2012-07-06 16:57:43 +0100
committerPaolo Capriotti <p.capriotti@gmail.com>2012-07-27 09:36:40 +0100
commit3afc015b072b6474520e94c1f58aa78175f17043 (patch)
tree2d5bc5f021a8f5d77766952edba0200325105376 /testsuite/tests/numeric
parentddbe79066991c2ffd464b975d50b3ccdec5c5c8c (diff)
downloadhaskell-3afc015b072b6474520e94c1f58aa78175f17043.tar.gz
Add test case for #7014.
Diffstat (limited to 'testsuite/tests/numeric')
-rw-r--r--testsuite/tests/numeric/should_run/Makefile7
-rw-r--r--testsuite/tests/numeric/should_run/T7014.hs91
-rw-r--r--testsuite/tests/numeric/should_run/T7014.primops12
-rw-r--r--testsuite/tests/numeric/should_run/T7014.stdout21
-rw-r--r--testsuite/tests/numeric/should_run/all.T4
5 files changed, 135 insertions, 0 deletions
diff --git a/testsuite/tests/numeric/should_run/Makefile b/testsuite/tests/numeric/should_run/Makefile
index 9101fbd40a..26ec990fee 100644
--- a/testsuite/tests/numeric/should_run/Makefile
+++ b/testsuite/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/testsuite/tests/numeric/should_run/T7014.hs b/testsuite/tests/numeric/should_run/T7014.hs
new file mode 100644
index 0000000000..82375389d7
--- /dev/null
+++ b/testsuite/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/testsuite/tests/numeric/should_run/T7014.primops b/testsuite/tests/numeric/should_run/T7014.primops
new file mode 100644
index 0000000000..3243666dbc
--- /dev/null
+++ b/testsuite/tests/numeric/should_run/T7014.primops
@@ -0,0 +1,12 @@
+and#
+or#
+uncheckedShift.*#
+\+#
+\-#
+\*#
+quotInt#
+remInt#
+plusFloat#
+minusFloat#
+timesFloat#
+divideFloat#
diff --git a/testsuite/tests/numeric/should_run/T7014.stdout b/testsuite/tests/numeric/should_run/T7014.stdout
new file mode 100644
index 0000000000..749a8f6d9a
--- /dev/null
+++ b/testsuite/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/testsuite/tests/numeric/should_run/all.T b/testsuite/tests/numeric/should_run/all.T
index 3e12a88320..9244ac7101 100644
--- a/testsuite/tests/numeric/should_run/all.T
+++ b/testsuite/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'])