diff options
Diffstat (limited to 'testsuite/tests/primops/should_run/CmpWord8.hs')
-rw-r--r-- | testsuite/tests/primops/should_run/CmpWord8.hs | 84 |
1 files changed, 0 insertions, 84 deletions
diff --git a/testsuite/tests/primops/should_run/CmpWord8.hs b/testsuite/tests/primops/should_run/CmpWord8.hs deleted file mode 100644 index 101f7837b5..0000000000 --- a/testsuite/tests/primops/should_run/CmpWord8.hs +++ /dev/null @@ -1,84 +0,0 @@ -{-# LANGUAGE BangPatterns #-} -{-# LANGUAGE MagicHash #-} - -module Main where - -import Data.Word -import Data.List -import GHC.Prim -import GHC.Exts - - --- Having a wrapper gives us two things: --- * it's easier to test everything (no need for code using raw primops) --- * we test the deriving mechanism for Word8# -data TestWord8 = T8 Word8# - deriving (Eq, Ord) - -mkT8 :: Word -> TestWord8 -mkT8 (W# a) = T8 (narrowWord8# a) - -main :: IO () -main = do - let input = [ (a, b) | a <- allWord8, b <- allWord8 ] - - -- - -- (==) - -- - let expected = [ a == b | (a, b) <- input ] - actual = [ mkT8 a == mkT8 b | (a, b) <- input ] - checkResults "(==)" input expected actual - - -- - -- (/=) - -- - let expected = [ a /= b | (a, b) <- input ] - actual = [ mkT8 a /= mkT8 b | (a, b) <- input ] - checkResults "(/=)" input expected actual - - -- - -- (<) - -- - let expected = [ a < b | (a, b) <- input ] - actual = [ mkT8 a < mkT8 b | (a, b) <- input ] - checkResults "(<)" input expected actual - - -- - -- (>) - -- - let expected = [ a > b | (a, b) <- input ] - actual = [ mkT8 a > mkT8 b | (a, b) <- input ] - checkResults "(>)" input expected actual - - -- - -- (<=) - -- - let expected = [ a <= b | (a, b) <- input ] - actual = [ mkT8 a <= mkT8 b | (a, b) <- input ] - checkResults "(<=)" input expected actual - - -- - -- (>=) - -- - let expected = [ a >= b | (a, b) <- input ] - actual = [ mkT8 a >= mkT8 b | (a, b) <- input ] - checkResults "(>=)" input expected actual - -checkResults - :: (Eq a, Eq b, Show a, Show b) => String -> [a] -> [b] -> [b] -> IO () -checkResults test inputs expected actual = - case findIndex (\(e, a) -> e /= a) (zip expected actual) of - Nothing -> putStrLn $ "Pass: " ++ test - Just i -> error $ - "FAILED: " ++ test ++ " for input: " ++ show (inputs !! i) - ++ " expected: " ++ show (expected !! i) - ++ " but got: " ++ show (actual !! i) - -allWord8 :: [Word] -allWord8 = [ minWord8 .. maxWord8 ] - -minWord8 :: Word -minWord8 = fromIntegral (minBound :: Word8) - -maxWord8 :: Word -maxWord8 = fromIntegral (maxBound :: Word8) |