{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE DeriveDataTypeable  #-}
{-# LANGUAGE TemplateHaskell     #-}
{-# LANGUAGE TypeOperators       #-}
-- |
-- Module      : Data.Array.Accelerate.Test.NoFib.Config
-- Copyright   : [2009..2020] The Accelerate Team
-- License     : BSD3
--
-- Maintainer  : Trevor L. McDonell <trevor.mcdonell@gmail.com>
-- Stability   : experimental
-- Portability : non-portable (GHC extensions)
--

module Data.Array.Accelerate.Test.NoFib.Config
  where

import Data.Bits
import Data.Proxy
import Data.Typeable

import Test.Tasty
import Test.Tasty.Ingredients
import Test.Tasty.Options


nofibIngredient :: Ingredient
nofibIngredient :: Ingredient
nofibIngredient =
  [OptionDescription] -> Ingredient
includingOptions
    [ Proxy TestHalf -> OptionDescription
forall v. IsOption v => Proxy v -> OptionDescription
Option (Proxy TestHalf
forall k (t :: k). Proxy t
Proxy::Proxy TestHalf)
    , Proxy TestFloat -> OptionDescription
forall v. IsOption v => Proxy v -> OptionDescription
Option (Proxy TestFloat
forall k (t :: k). Proxy t
Proxy::Proxy TestFloat)
    , Proxy TestDouble -> OptionDescription
forall v. IsOption v => Proxy v -> OptionDescription
Option (Proxy TestDouble
forall k (t :: k). Proxy t
Proxy::Proxy TestDouble)
    , Proxy TestInt8 -> OptionDescription
forall v. IsOption v => Proxy v -> OptionDescription
Option (Proxy TestInt8
forall k (t :: k). Proxy t
Proxy::Proxy TestInt8)
    , Proxy TestInt16 -> OptionDescription
forall v. IsOption v => Proxy v -> OptionDescription
Option (Proxy TestInt16
forall k (t :: k). Proxy t
Proxy::Proxy TestInt16)
    , Proxy TestInt32 -> OptionDescription
forall v. IsOption v => Proxy v -> OptionDescription
Option (Proxy TestInt32
forall k (t :: k). Proxy t
Proxy::Proxy TestInt32)
    , Proxy TestInt64 -> OptionDescription
forall v. IsOption v => Proxy v -> OptionDescription
Option (Proxy TestInt64
forall k (t :: k). Proxy t
Proxy::Proxy TestInt64)
    , Proxy TestWord8 -> OptionDescription
forall v. IsOption v => Proxy v -> OptionDescription
Option (Proxy TestWord8
forall k (t :: k). Proxy t
Proxy::Proxy TestWord8)
    , Proxy TestWord16 -> OptionDescription
forall v. IsOption v => Proxy v -> OptionDescription
Option (Proxy TestWord16
forall k (t :: k). Proxy t
Proxy::Proxy TestWord16)
    , Proxy TestWord32 -> OptionDescription
forall v. IsOption v => Proxy v -> OptionDescription
Option (Proxy TestWord32
forall k (t :: k). Proxy t
Proxy::Proxy TestWord32)
    , Proxy TestWord64 -> OptionDescription
forall v. IsOption v => Proxy v -> OptionDescription
Option (Proxy TestWord64
forall k (t :: k). Proxy t
Proxy::Proxy TestWord64)
    , Proxy Interpreter -> OptionDescription
forall v. IsOption v => Proxy v -> OptionDescription
Option (Proxy Interpreter
forall k (t :: k). Proxy t
Proxy::Proxy Interpreter)
    ]

newtype TestAll     = TestAll     Bool deriving (TestAll -> TestAll -> Bool
(TestAll -> TestAll -> Bool)
-> (TestAll -> TestAll -> Bool) -> Eq TestAll
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TestAll -> TestAll -> Bool
$c/= :: TestAll -> TestAll -> Bool
== :: TestAll -> TestAll -> Bool
$c== :: TestAll -> TestAll -> Bool
Eq, Int -> TestAll -> ShowS
[TestAll] -> ShowS
TestAll -> String
(Int -> TestAll -> ShowS)
-> (TestAll -> String) -> ([TestAll] -> ShowS) -> Show TestAll
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TestAll] -> ShowS
$cshowList :: [TestAll] -> ShowS
show :: TestAll -> String
$cshow :: TestAll -> String
showsPrec :: Int -> TestAll -> ShowS
$cshowsPrec :: Int -> TestAll -> ShowS
Show, Typeable)
newtype TestHalf    = TestHalf    Bool deriving (TestHalf -> TestHalf -> Bool
(TestHalf -> TestHalf -> Bool)
-> (TestHalf -> TestHalf -> Bool) -> Eq TestHalf
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TestHalf -> TestHalf -> Bool
$c/= :: TestHalf -> TestHalf -> Bool
== :: TestHalf -> TestHalf -> Bool
$c== :: TestHalf -> TestHalf -> Bool
Eq, Int -> TestHalf -> ShowS
[TestHalf] -> ShowS
TestHalf -> String
(Int -> TestHalf -> ShowS)
-> (TestHalf -> String) -> ([TestHalf] -> ShowS) -> Show TestHalf
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TestHalf] -> ShowS
$cshowList :: [TestHalf] -> ShowS
show :: TestHalf -> String
$cshow :: TestHalf -> String
showsPrec :: Int -> TestHalf -> ShowS
$cshowsPrec :: Int -> TestHalf -> ShowS
Show, Typeable)
newtype TestFloat   = TestFloat   Bool deriving (TestFloat -> TestFloat -> Bool
(TestFloat -> TestFloat -> Bool)
-> (TestFloat -> TestFloat -> Bool) -> Eq TestFloat
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TestFloat -> TestFloat -> Bool
$c/= :: TestFloat -> TestFloat -> Bool
== :: TestFloat -> TestFloat -> Bool
$c== :: TestFloat -> TestFloat -> Bool
Eq, Int -> TestFloat -> ShowS
[TestFloat] -> ShowS
TestFloat -> String
(Int -> TestFloat -> ShowS)
-> (TestFloat -> String)
-> ([TestFloat] -> ShowS)
-> Show TestFloat
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TestFloat] -> ShowS
$cshowList :: [TestFloat] -> ShowS
show :: TestFloat -> String
$cshow :: TestFloat -> String
showsPrec :: Int -> TestFloat -> ShowS
$cshowsPrec :: Int -> TestFloat -> ShowS
Show, Typeable)
newtype TestDouble  = TestDouble  Bool deriving (TestDouble -> TestDouble -> Bool
(TestDouble -> TestDouble -> Bool)
-> (TestDouble -> TestDouble -> Bool) -> Eq TestDouble
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TestDouble -> TestDouble -> Bool
$c/= :: TestDouble -> TestDouble -> Bool
== :: TestDouble -> TestDouble -> Bool
$c== :: TestDouble -> TestDouble -> Bool
Eq, Int -> TestDouble -> ShowS
[TestDouble] -> ShowS
TestDouble -> String
(Int -> TestDouble -> ShowS)
-> (TestDouble -> String)
-> ([TestDouble] -> ShowS)
-> Show TestDouble
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TestDouble] -> ShowS
$cshowList :: [TestDouble] -> ShowS
show :: TestDouble -> String
$cshow :: TestDouble -> String
showsPrec :: Int -> TestDouble -> ShowS
$cshowsPrec :: Int -> TestDouble -> ShowS
Show, Typeable)
newtype TestInt8    = TestInt8    Bool deriving (TestInt8 -> TestInt8 -> Bool
(TestInt8 -> TestInt8 -> Bool)
-> (TestInt8 -> TestInt8 -> Bool) -> Eq TestInt8
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TestInt8 -> TestInt8 -> Bool
$c/= :: TestInt8 -> TestInt8 -> Bool
== :: TestInt8 -> TestInt8 -> Bool
$c== :: TestInt8 -> TestInt8 -> Bool
Eq, Int -> TestInt8 -> ShowS
[TestInt8] -> ShowS
TestInt8 -> String
(Int -> TestInt8 -> ShowS)
-> (TestInt8 -> String) -> ([TestInt8] -> ShowS) -> Show TestInt8
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TestInt8] -> ShowS
$cshowList :: [TestInt8] -> ShowS
show :: TestInt8 -> String
$cshow :: TestInt8 -> String
showsPrec :: Int -> TestInt8 -> ShowS
$cshowsPrec :: Int -> TestInt8 -> ShowS
Show, Typeable)
newtype TestInt16   = TestInt16   Bool deriving (TestInt16 -> TestInt16 -> Bool
(TestInt16 -> TestInt16 -> Bool)
-> (TestInt16 -> TestInt16 -> Bool) -> Eq TestInt16
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TestInt16 -> TestInt16 -> Bool
$c/= :: TestInt16 -> TestInt16 -> Bool
== :: TestInt16 -> TestInt16 -> Bool
$c== :: TestInt16 -> TestInt16 -> Bool
Eq, Int -> TestInt16 -> ShowS
[TestInt16] -> ShowS
TestInt16 -> String
(Int -> TestInt16 -> ShowS)
-> (TestInt16 -> String)
-> ([TestInt16] -> ShowS)
-> Show TestInt16
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TestInt16] -> ShowS
$cshowList :: [TestInt16] -> ShowS
show :: TestInt16 -> String
$cshow :: TestInt16 -> String
showsPrec :: Int -> TestInt16 -> ShowS
$cshowsPrec :: Int -> TestInt16 -> ShowS
Show, Typeable)
newtype TestInt32   = TestInt32   Bool deriving (TestInt32 -> TestInt32 -> Bool
(TestInt32 -> TestInt32 -> Bool)
-> (TestInt32 -> TestInt32 -> Bool) -> Eq TestInt32
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TestInt32 -> TestInt32 -> Bool
$c/= :: TestInt32 -> TestInt32 -> Bool
== :: TestInt32 -> TestInt32 -> Bool
$c== :: TestInt32 -> TestInt32 -> Bool
Eq, Int -> TestInt32 -> ShowS
[TestInt32] -> ShowS
TestInt32 -> String
(Int -> TestInt32 -> ShowS)
-> (TestInt32 -> String)
-> ([TestInt32] -> ShowS)
-> Show TestInt32
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TestInt32] -> ShowS
$cshowList :: [TestInt32] -> ShowS
show :: TestInt32 -> String
$cshow :: TestInt32 -> String
showsPrec :: Int -> TestInt32 -> ShowS
$cshowsPrec :: Int -> TestInt32 -> ShowS
Show, Typeable)
newtype TestInt64   = TestInt64   Bool deriving (TestInt64 -> TestInt64 -> Bool
(TestInt64 -> TestInt64 -> Bool)
-> (TestInt64 -> TestInt64 -> Bool) -> Eq TestInt64
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TestInt64 -> TestInt64 -> Bool
$c/= :: TestInt64 -> TestInt64 -> Bool
== :: TestInt64 -> TestInt64 -> Bool
$c== :: TestInt64 -> TestInt64 -> Bool
Eq, Int -> TestInt64 -> ShowS
[TestInt64] -> ShowS
TestInt64 -> String
(Int -> TestInt64 -> ShowS)
-> (TestInt64 -> String)
-> ([TestInt64] -> ShowS)
-> Show TestInt64
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TestInt64] -> ShowS
$cshowList :: [TestInt64] -> ShowS
show :: TestInt64 -> String
$cshow :: TestInt64 -> String
showsPrec :: Int -> TestInt64 -> ShowS
$cshowsPrec :: Int -> TestInt64 -> ShowS
Show, Typeable)
newtype TestWord8   = TestWord8   Bool deriving (TestWord8 -> TestWord8 -> Bool
(TestWord8 -> TestWord8 -> Bool)
-> (TestWord8 -> TestWord8 -> Bool) -> Eq TestWord8
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TestWord8 -> TestWord8 -> Bool
$c/= :: TestWord8 -> TestWord8 -> Bool
== :: TestWord8 -> TestWord8 -> Bool
$c== :: TestWord8 -> TestWord8 -> Bool
Eq, Int -> TestWord8 -> ShowS
[TestWord8] -> ShowS
TestWord8 -> String
(Int -> TestWord8 -> ShowS)
-> (TestWord8 -> String)
-> ([TestWord8] -> ShowS)
-> Show TestWord8
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TestWord8] -> ShowS
$cshowList :: [TestWord8] -> ShowS
show :: TestWord8 -> String
$cshow :: TestWord8 -> String
showsPrec :: Int -> TestWord8 -> ShowS
$cshowsPrec :: Int -> TestWord8 -> ShowS
Show, Typeable)
newtype TestWord16  = TestWord16  Bool deriving (TestWord16 -> TestWord16 -> Bool
(TestWord16 -> TestWord16 -> Bool)
-> (TestWord16 -> TestWord16 -> Bool) -> Eq TestWord16
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TestWord16 -> TestWord16 -> Bool
$c/= :: TestWord16 -> TestWord16 -> Bool
== :: TestWord16 -> TestWord16 -> Bool
$c== :: TestWord16 -> TestWord16 -> Bool
Eq, Int -> TestWord16 -> ShowS
[TestWord16] -> ShowS
TestWord16 -> String
(Int -> TestWord16 -> ShowS)
-> (TestWord16 -> String)
-> ([TestWord16] -> ShowS)
-> Show TestWord16
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TestWord16] -> ShowS
$cshowList :: [TestWord16] -> ShowS
show :: TestWord16 -> String
$cshow :: TestWord16 -> String
showsPrec :: Int -> TestWord16 -> ShowS
$cshowsPrec :: Int -> TestWord16 -> ShowS
Show, Typeable)
newtype TestWord32  = TestWord32  Bool deriving (TestWord32 -> TestWord32 -> Bool
(TestWord32 -> TestWord32 -> Bool)
-> (TestWord32 -> TestWord32 -> Bool) -> Eq TestWord32
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TestWord32 -> TestWord32 -> Bool
$c/= :: TestWord32 -> TestWord32 -> Bool
== :: TestWord32 -> TestWord32 -> Bool
$c== :: TestWord32 -> TestWord32 -> Bool
Eq, Int -> TestWord32 -> ShowS
[TestWord32] -> ShowS
TestWord32 -> String
(Int -> TestWord32 -> ShowS)
-> (TestWord32 -> String)
-> ([TestWord32] -> ShowS)
-> Show TestWord32
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TestWord32] -> ShowS
$cshowList :: [TestWord32] -> ShowS
show :: TestWord32 -> String
$cshow :: TestWord32 -> String
showsPrec :: Int -> TestWord32 -> ShowS
$cshowsPrec :: Int -> TestWord32 -> ShowS
Show, Typeable)
newtype TestWord64  = TestWord64  Bool deriving (TestWord64 -> TestWord64 -> Bool
(TestWord64 -> TestWord64 -> Bool)
-> (TestWord64 -> TestWord64 -> Bool) -> Eq TestWord64
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TestWord64 -> TestWord64 -> Bool
$c/= :: TestWord64 -> TestWord64 -> Bool
== :: TestWord64 -> TestWord64 -> Bool
$c== :: TestWord64 -> TestWord64 -> Bool
Eq, Int -> TestWord64 -> ShowS
[TestWord64] -> ShowS
TestWord64 -> String
(Int -> TestWord64 -> ShowS)
-> (TestWord64 -> String)
-> ([TestWord64] -> ShowS)
-> Show TestWord64
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TestWord64] -> ShowS
$cshowList :: [TestWord64] -> ShowS
show :: TestWord64 -> String
$cshow :: TestWord64 -> String
showsPrec :: Int -> TestWord64 -> ShowS
$cshowsPrec :: Int -> TestWord64 -> ShowS
Show, Typeable)
newtype Interpreter = Interpreter Bool deriving (Interpreter -> Interpreter -> Bool
(Interpreter -> Interpreter -> Bool)
-> (Interpreter -> Interpreter -> Bool) -> Eq Interpreter
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Interpreter -> Interpreter -> Bool
$c/= :: Interpreter -> Interpreter -> Bool
== :: Interpreter -> Interpreter -> Bool
$c== :: Interpreter -> Interpreter -> Bool
Eq, Int -> Interpreter -> ShowS
[Interpreter] -> ShowS
Interpreter -> String
(Int -> Interpreter -> ShowS)
-> (Interpreter -> String)
-> ([Interpreter] -> ShowS)
-> Show Interpreter
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Interpreter] -> ShowS
$cshowList :: [Interpreter] -> ShowS
show :: Interpreter -> String
$cshow :: Interpreter -> String
showsPrec :: Int -> Interpreter -> ShowS
$cshowsPrec :: Int -> Interpreter -> ShowS
Show, Typeable)

instance IsOption TestAll where
  defaultValue :: TestAll
defaultValue = Bool -> TestAll
TestAll Bool
False
  parseValue :: String -> Maybe TestAll
parseValue = (Bool -> TestAll) -> Maybe Bool -> Maybe TestAll
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Bool -> TestAll
TestAll (Maybe Bool -> Maybe TestAll)
-> (String -> Maybe Bool) -> String -> Maybe TestAll
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Maybe Bool
forall a. Read a => String -> Maybe a
safeRead
  optionName :: Tagged TestAll String
optionName = String -> Tagged TestAll String
forall (m :: * -> *) a. Monad m => a -> m a
return String
"all-types"
  optionHelp :: Tagged TestAll String
optionHelp = String -> Tagged TestAll String
forall (m :: * -> *) a. Monad m => a -> m a
return String
"Enable tests on all primitive types"

instance IsOption TestHalf where
  defaultValue :: TestHalf
defaultValue = Bool -> TestHalf
TestHalf Bool
False
  parseValue :: String -> Maybe TestHalf
parseValue = (Bool -> TestHalf) -> Maybe Bool -> Maybe TestHalf
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Bool -> TestHalf
TestHalf (Maybe Bool -> Maybe TestHalf)
-> (String -> Maybe Bool) -> String -> Maybe TestHalf
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Maybe Bool
forall a. Read a => String -> Maybe a
safeRead
  optionName :: Tagged TestHalf String
optionName = String -> Tagged TestHalf String
forall (m :: * -> *) a. Monad m => a -> m a
return String
"half"
  optionHelp :: Tagged TestHalf String
optionHelp = String -> Tagged TestHalf String
forall (m :: * -> *) a. Monad m => a -> m a
return String
"Enable half-precision tests"

instance IsOption TestFloat where
  defaultValue :: TestFloat
defaultValue = Bool -> TestFloat
TestFloat Bool
False
  parseValue :: String -> Maybe TestFloat
parseValue = (Bool -> TestFloat) -> Maybe Bool -> Maybe TestFloat
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Bool -> TestFloat
TestFloat (Maybe Bool -> Maybe TestFloat)
-> (String -> Maybe Bool) -> String -> Maybe TestFloat
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Maybe Bool
forall a. Read a => String -> Maybe a
safeRead
  optionName :: Tagged TestFloat String
optionName = String -> Tagged TestFloat String
forall (m :: * -> *) a. Monad m => a -> m a
return String
"float"
  optionHelp :: Tagged TestFloat String
optionHelp = String -> Tagged TestFloat String
forall (m :: * -> *) a. Monad m => a -> m a
return String
"Enable single-precision tests"

instance IsOption TestDouble where
  defaultValue :: TestDouble
defaultValue = Bool -> TestDouble
TestDouble Bool
True
  parseValue :: String -> Maybe TestDouble
parseValue = (Bool -> TestDouble) -> Maybe Bool -> Maybe TestDouble
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Bool -> TestDouble
TestDouble (Maybe Bool -> Maybe TestDouble)
-> (String -> Maybe Bool) -> String -> Maybe TestDouble
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Maybe Bool
forall a. Read a => String -> Maybe a
safeRead
  optionName :: Tagged TestDouble String
optionName = String -> Tagged TestDouble String
forall (m :: * -> *) a. Monad m => a -> m a
return String
"double"
  optionHelp :: Tagged TestDouble String
optionHelp = String -> Tagged TestDouble String
forall (m :: * -> *) a. Monad m => a -> m a
return String
"Enable double-precision tests"

instance IsOption TestInt8 where
  defaultValue :: TestInt8
defaultValue = Bool -> TestInt8
TestInt8 Bool
False
  parseValue :: String -> Maybe TestInt8
parseValue = (Bool -> TestInt8) -> Maybe Bool -> Maybe TestInt8
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Bool -> TestInt8
TestInt8 (Maybe Bool -> Maybe TestInt8)
-> (String -> Maybe Bool) -> String -> Maybe TestInt8
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Maybe Bool
forall a. Read a => String -> Maybe a
safeRead
  optionName :: Tagged TestInt8 String
optionName = String -> Tagged TestInt8 String
forall (m :: * -> *) a. Monad m => a -> m a
return String
"int8"
  optionHelp :: Tagged TestInt8 String
optionHelp = String -> Tagged TestInt8 String
forall (m :: * -> *) a. Monad m => a -> m a
return String
"Enable 8-bit signed integer tests"

instance IsOption TestInt16 where
  defaultValue :: TestInt16
defaultValue = Bool -> TestInt16
TestInt16 Bool
False
  parseValue :: String -> Maybe TestInt16
parseValue = (Bool -> TestInt16) -> Maybe Bool -> Maybe TestInt16
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Bool -> TestInt16
TestInt16 (Maybe Bool -> Maybe TestInt16)
-> (String -> Maybe Bool) -> String -> Maybe TestInt16
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Maybe Bool
forall a. Read a => String -> Maybe a
safeRead
  optionName :: Tagged TestInt16 String
optionName = String -> Tagged TestInt16 String
forall (m :: * -> *) a. Monad m => a -> m a
return String
"int16"
  optionHelp :: Tagged TestInt16 String
optionHelp = String -> Tagged TestInt16 String
forall (m :: * -> *) a. Monad m => a -> m a
return String
"Enable 16-bit signed integer tests"

instance IsOption TestInt32 where
  defaultValue :: TestInt32
defaultValue = Bool -> TestInt32
TestInt32 $( [e| finiteBitSize (undefined::Int) == 32 |] )
  parseValue :: String -> Maybe TestInt32
parseValue = (Bool -> TestInt32) -> Maybe Bool -> Maybe TestInt32
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Bool -> TestInt32
TestInt32 (Maybe Bool -> Maybe TestInt32)
-> (String -> Maybe Bool) -> String -> Maybe TestInt32
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Maybe Bool
forall a. Read a => String -> Maybe a
safeRead
  optionName :: Tagged TestInt32 String
optionName = String -> Tagged TestInt32 String
forall (m :: * -> *) a. Monad m => a -> m a
return String
"int32"
  optionHelp :: Tagged TestInt32 String
optionHelp = String -> Tagged TestInt32 String
forall (m :: * -> *) a. Monad m => a -> m a
return String
"Enable 32-bit signed integer tests"

instance IsOption TestInt64 where
  defaultValue :: TestInt64
defaultValue = Bool -> TestInt64
TestInt64 $( [e| finiteBitSize (undefined::Int) == 64 |] )
  parseValue :: String -> Maybe TestInt64
parseValue = (Bool -> TestInt64) -> Maybe Bool -> Maybe TestInt64
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Bool -> TestInt64
TestInt64 (Maybe Bool -> Maybe TestInt64)
-> (String -> Maybe Bool) -> String -> Maybe TestInt64
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Maybe Bool
forall a. Read a => String -> Maybe a
safeRead
  optionName :: Tagged TestInt64 String
optionName = String -> Tagged TestInt64 String
forall (m :: * -> *) a. Monad m => a -> m a
return String
"int64"
  optionHelp :: Tagged TestInt64 String
optionHelp = String -> Tagged TestInt64 String
forall (m :: * -> *) a. Monad m => a -> m a
return String
"Enable 64-bit signed integer tests"

instance IsOption TestWord8 where
  defaultValue :: TestWord8
defaultValue = Bool -> TestWord8
TestWord8 Bool
False
  parseValue :: String -> Maybe TestWord8
parseValue = (Bool -> TestWord8) -> Maybe Bool -> Maybe TestWord8
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Bool -> TestWord8
TestWord8 (Maybe Bool -> Maybe TestWord8)
-> (String -> Maybe Bool) -> String -> Maybe TestWord8
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Maybe Bool
forall a. Read a => String -> Maybe a
safeRead
  optionName :: Tagged TestWord8 String
optionName = String -> Tagged TestWord8 String
forall (m :: * -> *) a. Monad m => a -> m a
return String
"word8"
  optionHelp :: Tagged TestWord8 String
optionHelp = String -> Tagged TestWord8 String
forall (m :: * -> *) a. Monad m => a -> m a
return String
"Enable 8-bit unsigned integer tests"

instance IsOption TestWord16 where
  defaultValue :: TestWord16
defaultValue = Bool -> TestWord16
TestWord16 Bool
False
  parseValue :: String -> Maybe TestWord16
parseValue = (Bool -> TestWord16) -> Maybe Bool -> Maybe TestWord16
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Bool -> TestWord16
TestWord16 (Maybe Bool -> Maybe TestWord16)
-> (String -> Maybe Bool) -> String -> Maybe TestWord16
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Maybe Bool
forall a. Read a => String -> Maybe a
safeRead
  optionName :: Tagged TestWord16 String
optionName = String -> Tagged TestWord16 String
forall (m :: * -> *) a. Monad m => a -> m a
return String
"word16"
  optionHelp :: Tagged TestWord16 String
optionHelp = String -> Tagged TestWord16 String
forall (m :: * -> *) a. Monad m => a -> m a
return String
"Enable 16-bit unsigned integer tests"

instance IsOption TestWord32 where
  defaultValue :: TestWord32
defaultValue = Bool -> TestWord32
TestWord32 Bool
False
  parseValue :: String -> Maybe TestWord32
parseValue = (Bool -> TestWord32) -> Maybe Bool -> Maybe TestWord32
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Bool -> TestWord32
TestWord32 (Maybe Bool -> Maybe TestWord32)
-> (String -> Maybe Bool) -> String -> Maybe TestWord32
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Maybe Bool
forall a. Read a => String -> Maybe a
safeRead
  optionName :: Tagged TestWord32 String
optionName = String -> Tagged TestWord32 String
forall (m :: * -> *) a. Monad m => a -> m a
return String
"word32"
  optionHelp :: Tagged TestWord32 String
optionHelp = String -> Tagged TestWord32 String
forall (m :: * -> *) a. Monad m => a -> m a
return String
"Enable 32-bit unsigned integer tests"

instance IsOption TestWord64 where
  defaultValue :: TestWord64
defaultValue = Bool -> TestWord64
TestWord64 Bool
False
  parseValue :: String -> Maybe TestWord64
parseValue = (Bool -> TestWord64) -> Maybe Bool -> Maybe TestWord64
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Bool -> TestWord64
TestWord64 (Maybe Bool -> Maybe TestWord64)
-> (String -> Maybe Bool) -> String -> Maybe TestWord64
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Maybe Bool
forall a. Read a => String -> Maybe a
safeRead
  optionName :: Tagged TestWord64 String
optionName = String -> Tagged TestWord64 String
forall (m :: * -> *) a. Monad m => a -> m a
return String
"word64"
  optionHelp :: Tagged TestWord64 String
optionHelp = String -> Tagged TestWord64 String
forall (m :: * -> *) a. Monad m => a -> m a
return String
"Enable 64-bit unsigned integer tests"

instance IsOption Interpreter where
  defaultValue :: Interpreter
defaultValue = Bool -> Interpreter
Interpreter Bool
False
  parseValue :: String -> Maybe Interpreter
parseValue = (Bool -> Interpreter) -> Maybe Bool -> Maybe Interpreter
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Bool -> Interpreter
Interpreter (Maybe Bool -> Maybe Interpreter)
-> (String -> Maybe Bool) -> String -> Maybe Interpreter
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Maybe Bool
forall a. Read a => String -> Maybe a
safeRead
  optionName :: Tagged Interpreter String
optionName = String -> Tagged Interpreter String
forall (m :: * -> *) a. Monad m => a -> m a
return String
"interpreter"
  optionHelp :: Tagged Interpreter String
optionHelp = String -> Tagged Interpreter String
forall (m :: * -> *) a. Monad m => a -> m a
return String
"I am an interpreter (skip some tests)"


class IsOption a => TestConfig a where
  at :: TestTree -> TestTree

instance TestConfig TestHalf where
  at :: TestTree -> TestTree
at TestTree
t = (TestHalf -> TestTree) -> TestTree
forall v. IsOption v => (v -> TestTree) -> TestTree
askOption ((TestHalf -> TestTree) -> TestTree)
-> (TestHalf -> TestTree) -> TestTree
forall a b. (a -> b) -> a -> b
$ \(TestHalf Bool
v)   -> if Bool
v then TestTree
t else String -> [TestTree] -> TestTree
testGroup String
"Half" []

instance TestConfig TestFloat where
  at :: TestTree -> TestTree
at TestTree
t = (TestFloat -> TestTree) -> TestTree
forall v. IsOption v => (v -> TestTree) -> TestTree
askOption ((TestFloat -> TestTree) -> TestTree)
-> (TestFloat -> TestTree) -> TestTree
forall a b. (a -> b) -> a -> b
$ \(TestFloat Bool
v)  -> if Bool
v then TestTree
t else String -> [TestTree] -> TestTree
testGroup String
"Float" []

instance TestConfig TestDouble where
  at :: TestTree -> TestTree
at TestTree
t = (TestDouble -> TestTree) -> TestTree
forall v. IsOption v => (v -> TestTree) -> TestTree
askOption ((TestDouble -> TestTree) -> TestTree)
-> (TestDouble -> TestTree) -> TestTree
forall a b. (a -> b) -> a -> b
$ \(TestDouble Bool
v) -> if Bool
v then TestTree
t else String -> [TestTree] -> TestTree
testGroup String
"Double" []

instance TestConfig TestInt8 where
  at :: TestTree -> TestTree
at TestTree
t = (TestInt8 -> TestTree) -> TestTree
forall v. IsOption v => (v -> TestTree) -> TestTree
askOption ((TestInt8 -> TestTree) -> TestTree)
-> (TestInt8 -> TestTree) -> TestTree
forall a b. (a -> b) -> a -> b
$ \(TestInt8 Bool
v)   -> if Bool
v then TestTree
t else String -> [TestTree] -> TestTree
testGroup String
"Int8" []

instance TestConfig TestInt16 where
  at :: TestTree -> TestTree
at TestTree
t = (TestInt16 -> TestTree) -> TestTree
forall v. IsOption v => (v -> TestTree) -> TestTree
askOption ((TestInt16 -> TestTree) -> TestTree)
-> (TestInt16 -> TestTree) -> TestTree
forall a b. (a -> b) -> a -> b
$ \(TestInt16 Bool
v)  -> if Bool
v then TestTree
t else String -> [TestTree] -> TestTree
testGroup String
"Int16" []

instance TestConfig TestInt32 where
  at :: TestTree -> TestTree
at TestTree
t = (TestInt32 -> TestTree) -> TestTree
forall v. IsOption v => (v -> TestTree) -> TestTree
askOption ((TestInt32 -> TestTree) -> TestTree)
-> (TestInt32 -> TestTree) -> TestTree
forall a b. (a -> b) -> a -> b
$ \(TestInt32 Bool
v)  -> if Bool
v then TestTree
t else String -> [TestTree] -> TestTree
testGroup String
"Int32" []

instance TestConfig TestInt64 where
  at :: TestTree -> TestTree
at TestTree
t = (TestInt64 -> TestTree) -> TestTree
forall v. IsOption v => (v -> TestTree) -> TestTree
askOption ((TestInt64 -> TestTree) -> TestTree)
-> (TestInt64 -> TestTree) -> TestTree
forall a b. (a -> b) -> a -> b
$ \(TestInt64 Bool
v)  -> if Bool
v then TestTree
t else String -> [TestTree] -> TestTree
testGroup String
"Int64" []

instance TestConfig TestWord8 where
  at :: TestTree -> TestTree
at TestTree
t = (TestWord8 -> TestTree) -> TestTree
forall v. IsOption v => (v -> TestTree) -> TestTree
askOption ((TestWord8 -> TestTree) -> TestTree)
-> (TestWord8 -> TestTree) -> TestTree
forall a b. (a -> b) -> a -> b
$ \(TestWord8 Bool
v)  -> if Bool
v then TestTree
t else String -> [TestTree] -> TestTree
testGroup String
"Word8" []

instance TestConfig TestWord16 where
  at :: TestTree -> TestTree
at TestTree
t = (TestWord16 -> TestTree) -> TestTree
forall v. IsOption v => (v -> TestTree) -> TestTree
askOption ((TestWord16 -> TestTree) -> TestTree)
-> (TestWord16 -> TestTree) -> TestTree
forall a b. (a -> b) -> a -> b
$ \(TestWord16 Bool
v) -> if Bool
v then TestTree
t else String -> [TestTree] -> TestTree
testGroup String
"Word16" []

instance TestConfig TestWord32 where
  at :: TestTree -> TestTree
at TestTree
t = (TestWord32 -> TestTree) -> TestTree
forall v. IsOption v => (v -> TestTree) -> TestTree
askOption ((TestWord32 -> TestTree) -> TestTree)
-> (TestWord32 -> TestTree) -> TestTree
forall a b. (a -> b) -> a -> b
$ \(TestWord32 Bool
v) -> if Bool
v then TestTree
t else String -> [TestTree] -> TestTree
testGroup String
"Word32" []

instance TestConfig TestWord64 where
  at :: TestTree -> TestTree
at TestTree
t = (TestWord64 -> TestTree) -> TestTree
forall v. IsOption v => (v -> TestTree) -> TestTree
askOption ((TestWord64 -> TestTree) -> TestTree)
-> (TestWord64 -> TestTree) -> TestTree
forall a b. (a -> b) -> a -> b
$ \(TestWord64 Bool
v) -> if Bool
v then TestTree
t else String -> [TestTree] -> TestTree
testGroup String
"Word64" []