summaryrefslogtreecommitdiff
path: root/testsuite/tests/simplCore/should_run/simplrun007.hs
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/tests/simplCore/should_run/simplrun007.hs')
-rw-r--r--testsuite/tests/simplCore/should_run/simplrun007.hs27
1 files changed, 27 insertions, 0 deletions
diff --git a/testsuite/tests/simplCore/should_run/simplrun007.hs b/testsuite/tests/simplCore/should_run/simplrun007.hs
new file mode 100644
index 0000000000..12bfb2d335
--- /dev/null
+++ b/testsuite/tests/simplCore/should_run/simplrun007.hs
@@ -0,0 +1,27 @@
+{-# LANGUAGE MagicHash #-}
+
+-- Actually, this exercises prelude/PrelRules, but this is the closest
+-- place I could find to put it...
+
+import GHC.Exts
+import Numeric
+import Data.Bits
+
+main = do phex (I# (uncheckedIShiftL# (negateInt# 5#) 2#))
+ phex (I# (uncheckedIShiftRA# (negateInt# 5#) 1#))
+ phex (I# (uncheckedIShiftRL# (negateInt# 5#) 1#))
+ phex (W# (uncheckedShiftL# (int2Word# (negateInt# 5#)) 2#))
+ phex (W# (uncheckedShiftRL# (int2Word# (negateInt# 5#)) 1#))
+
+phex x = putStrLn (showSigned (\x -> ("0x"++) . showHex x) 0 x "")
+
+{- Too wordsize-dependant
+phex x = putStrLn (hex x)
+hex x = "0x" ++ [onedigit (fromIntegral ((x `shiftR` (i*4)) .&. 0xF))
+ | i <- [digits-1,digits-2..0]]
+ where
+ digits = bitSize x `div` 4
+ onedigit n = "0123456789abcdef" !! n
+-}
+
+