1{-# LANGUAGE TemplateHaskell #-}
4-- Module : Streamly.Test.Data.Serialize
5-- Copyright : (c) 2022 Composewell technologies
6-- License : BSD-3-Clause
7-- Maintainer : streamly@composewell.com
8-- Stability : experimental
11module Streamly.Test.Data.Serialize (main) where
13--------------------------------------------------------------------------------
15--------------------------------------------------------------------------------
17import Streamly.Internal.Data.Unbox (newBytes)
21import Streamly.Internal.Data.Serialize.TH (deriveSerialize)
22-- import Streamly.Internal.Data.Serialize (Serialize(..))
24import qualified Streamly.Internal.Data.Serialize as Serialize
26import Streamly.Test.Data.Serialize.TH (genDatatype)
28import Test.Hspec.QuickCheck
30--------------------------------------------------------------------------------
32--------------------------------------------------------------------------------
34$(genDatatype "CustomDatatype" 15)
35$(deriveSerialize ''CustomDatatype)
37--------------------------------------------------------------------------------
39--------------------------------------------------------------------------------
42 :: forall a. (Eq a, Show a, Serialize.Serialize a)
48 case Serialize.size :: Serialize.Size a of
49 Serialize.VarSize f -> f val
50 Serialize.ConstSize csz -> csz
54 off1 <- Serialize.serialize 0 arr val
55 (off2, val2) <- Serialize.deserialize 0 arr
60 :: forall a. (Eq a, Show a, Serialize.Serialize a)
64testSerializeList sizeOfA val = do
67 case Serialize.size :: Serialize.Size a of
68 Serialize.VarSize f -> f val
69 Serialize.ConstSize csz -> csz
75--------------------------------------------------------------------------------
77--------------------------------------------------------------------------------
83 $ testSerializeList (8 + 4 * 8) ([1, 2, 3, 4] :: [Int])
84 it "Serialize [[Int]]"
87 ([[1], [1, 2], [1, 2, 3]] :: [[Int]])
90 $ \(x :: CustomDatatype) -> roundtrip x
91 prop "[CustomDatatype]"
92 $ \(x :: [CustomDatatype]) -> roundtrip x
94--------------------------------------------------------------------------------
96--------------------------------------------------------------------------------
99moduleName = "Data.Unboxed"
102main = hspec $ H.parallel $ describe moduleName testCases
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list