diff options
Diffstat (limited to 'testsuite/tests/numeric/should_run/T18499.hs')
-rw-r--r-- | testsuite/tests/numeric/should_run/T18499.hs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/testsuite/tests/numeric/should_run/T18499.hs b/testsuite/tests/numeric/should_run/T18499.hs new file mode 100644 index 0000000000..059057015f --- /dev/null +++ b/testsuite/tests/numeric/should_run/T18499.hs @@ -0,0 +1,27 @@ +import Data.Bits +import Numeric.Natural +import GHC.Exception.Type +import Control.Exception + +main :: IO () +main = do + test ((42 `shiftR` (-1)) :: Integer) + test ((42 `shiftL` (-1)) :: Integer) + test ((42 `shiftR` (-1)) :: Natural) + test ((42 `shiftL` (-1)) :: Natural) + test ((42 `shiftR` (-1)) :: Word) + test ((42 `shiftL` (-1)) :: Word) + test ((42 `shiftR` (-1)) :: Int) + test ((42 `shiftL` (-1)) :: Int) + + test ((42 `unsafeShiftR` 2) :: Integer) + test ((42 `unsafeShiftL` 2) :: Integer) + test ((42 `unsafeShiftR` 2) :: Natural) + test ((42 `unsafeShiftL` 2) :: Natural) + test ((42 `unsafeShiftR` 2) :: Word) + test ((42 `unsafeShiftL` 2) :: Word) + test ((42 `unsafeShiftR` 2) :: Int) + test ((42 `unsafeShiftL` 2) :: Int) + +test :: Show a => a -> IO () +test a = print a `catch` (\Overflow -> putStrLn "Overflow!") |