@@ -2,11 +2,26 @@ module Streamly.Test.Data.Array.Unboxed.Mut (main) where
3import Test.QuickCheck (listOf)
3import Test.QuickCheck (listOf)
5+import Control.Monad (void)
6+import Data.Complex (Complex)
7+import Data.Functor.Const (Const)
8+import Data.Functor.Identity (Identity)
9+import Foreign.Ptr (IntPtr, WordPtr)
11+import GHC.Fingerprint.Type (Fingerprint(..))
12+import GHC.Int (Int16(..), Int32(..), Int64(..), Int8(..))
13+import GHC.Real (Ratio(..))
14+import GHC.Stable (StablePtr(..))
15+import GHC.Word (Word16(..), Word32(..), Word64(..), Word8(..))
16+import Streamly.Internal.Data.Unboxed (Unboxed)
5import Streamly.Test.Common (chooseInt)
17import Streamly.Test.Common (chooseInt)
6−import Test.Hspec (hspec, describe)
18+import Test.Hspec (hspec, describe, it)
7import Test.Hspec.QuickCheck
19import Test.Hspec.QuickCheck
8import Test.QuickCheck (forAll, Property)
20import Test.QuickCheck (forAll, Property)
9import Test.QuickCheck.Monadic (monadicIO, assert)
21import Test.QuickCheck.Monadic (monadicIO, assert)
22+#if MIN_VERSION_base(4,15,0)
23+import GHC.RTS.Flags (IoSubSystem(..))
11import qualified Streamly.Internal.Data.Array.Unboxed.Mut as MArray
26import qualified Streamly.Internal.Data.Array.Unboxed.Mut as MArray
12import qualified Streamly.Internal.Data.Stream as Stream
27import qualified Streamly.Internal.Data.Stream as Stream
@@ -32,6 +47,100 @@ testAppend =
32 lst <- MArray.toList x
47 lst <- MArray.toList x
33 assert (ls == lst)
48 assert (ls == lst)
50+#define TEST_IE(_type) it "_type" $ testIE ([] :: [_type])
52+-- XXX This should be in test/Data.Unbox
53+-- C-ish foreign types are platfor specific. The platform needs to be taken into
54+-- consideration when making instances.
55+testUnboxInstanceExistance :: Hspec.SpecWith ()
56+testUnboxInstanceExistance = do
57+ describe "Unbox instances" $ do
70+ -- TEST_IE(CSUSeconds)
72+ -- TEST_IE(CSigAtomic)
81+ -- TEST_IE(CUSeconds)
91+#if MIN_VERSION_base(4,15,0)
101+ -- TEST_IE(CClockId)
103+ -- TEST_IE(CFsBlkCnt)
104+ -- TEST_IE(CFsFilCnt)
115+ -- TEST_IE(CSocklen)
129+ TEST_IE(Complex Int)
130+ TEST_IE(Identity Int)
131+#if MIN_VERSION_base(4,14,0)
137+ TEST_IE(StablePtr Int)
138+ TEST_IE(Const Int Int)
141+ testIE :: Unboxed a => [a] -> IO ()
142+ testIE lst = void $ MArray.fromList lst
35main :: IO ()
144main :: IO ()
@@ -40,3 +149,4 @@ main =
40 describe moduleName $ do
149 describe moduleName $ do
41 describe "Stream Append" $ do
150 describe "Stream Append" $ do
42 prop "testAppend" testAppend
151 prop "testAppend" testAppend
152+ testUnboxInstanceExistance