Commit 0d5427fe by Samuel Bronson

### Add tests for bitshift PrelRules

parent 335e5511
 ... ... @@ -15,3 +15,4 @@ test('simplrun003', normal, compile_and_run, ['']) test('simplrun004', normal, compile_and_run, ['']) test('simplrun005', normal, compile_and_run, ['']) test('simplrun006', normal, compile_and_run, ['']) test('simplrun007', normal, compile_and_run, [''])
 {-# OPTIONS_GHC -fglasgow-exts #-} -- 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 -}
 -0x14 -0x3 0x7ffffffd 0xffffffec 0x7ffffffd
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!