packages feed

msgpack-arbitrary (empty) → 0.1.0

raw patch · 6 files changed

+130/−0 lines, 6 filesdep +QuickCheckdep +basedep +bytestringsetup-changed

Dependencies added: QuickCheck, base, bytestring, hspec, msgpack-arbitrary, msgpack-types, text, vector

Files

+ LICENSE view
@@ -0,0 +1,25 @@+Copyright (c) 2017-2018, The TokTok Team+Copyright (c) 2009-2010, Hideyuki Tanaka+All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:+    * Redistributions of source code must retain the above copyright+      notice, this list of conditions and the following disclaimer.+    * Redistributions in binary form must reproduce the above copyright+      notice, this list of conditions and the following disclaimer in the+      documentation and/or other materials provided with the distribution.+    * Neither the name of the Hideyuki Tanaka nor the+      names of its contributors may be used to endorse or promote products+      derived from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY Hideyuki Tanaka ''AS IS'' AND ANY+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE+DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ Setup.lhs view
@@ -0,0 +1,3 @@+#!/usr/bin/env runhaskell+> import Distribution.Simple+> main = defaultMain
+ msgpack-arbitrary.cabal view
@@ -0,0 +1,59 @@+name:                 msgpack-arbitrary+version:              0.1.0+synopsis:             A Haskell implementation of MessagePack.+homepage:             http://msgpack.org/+license:              BSD3+license-file:         LICENSE+author:               Hideyuki Tanaka+maintainer:           Iphigenia Df <iphydf@gmail.com>+copyright:            Copyright (c) 2009-2016, Hideyuki Tanaka+category:             Data+stability:            Experimental+cabal-version:        >= 1.10+build-type:           Simple+description:+  A Haskell implementation of MessagePack <http://msgpack.org/>+  .+  This is a fork of msgpack-haskell <https://github.com/msgpack/msgpack-haskell>,+  since the original author is unreachable. This fork incorporates a number of+  bugfixes and is actively being developed.++source-repository head+  type:             git+  location:         https://github.com/TokTok/hs-msgpack-arbitrary++library+  default-language: Haskell2010+  hs-source-dirs:+      src+  ghc-options:+      -Wall+      -fno-warn-unused-imports+  exposed-modules:+      Data.MessagePack.Arbitrary+  build-depends:+      base                      < 5+    , QuickCheck+    , bytestring+    , msgpack-types             >= 0.3 && < 0.4+    , text+    , vector++test-suite testsuite+  type: exitcode-stdio-1.0+  default-language: Haskell2010+  hs-source-dirs: test+  main-is: testsuite.hs+  other-modules:+      Data.MessagePack.ArbitrarySpec+  ghc-options:+      -Wall+      -fno-warn-unused-imports+  build-tool-depends:+      hspec-discover:hspec-discover+  build-depends:+      base < 5+    , QuickCheck+    , hspec+    , msgpack-arbitrary+    , msgpack-types
+ src/Data/MessagePack/Arbitrary.hs view
@@ -0,0 +1,28 @@+{-# OPTIONS_GHC -fno-warn-orphans #-}+{-# LANGUAGE StrictData  #-}+{-# LANGUAGE Trustworthy #-}+module Data.MessagePack.Arbitrary () where++import qualified Data.ByteString           as S+import           Data.MessagePack.Types    (Object (..))+import qualified Data.Text                 as T+import qualified Data.Vector               as V+import           Test.QuickCheck.Arbitrary (Arbitrary, arbitrary)+import qualified Test.QuickCheck.Gen       as Gen+++instance Arbitrary Object where+    arbitrary = Gen.sized $ \n -> Gen.oneof+        [ pure ObjectNil+        , ObjectBool   <$> arbitrary+        , ObjectInt    <$> negatives+        , ObjectWord   <$> arbitrary+        , ObjectFloat  <$> arbitrary+        , ObjectDouble <$> arbitrary+        , ObjectStr    <$> (T.pack <$> arbitrary)+        , ObjectBin    <$> (S.pack <$> arbitrary)+        , ObjectArray  <$> (V.fromList <$> Gen.resize (n `div` 2) arbitrary)+        , ObjectMap    <$> (V.fromList <$> Gen.resize (n `div` 4) arbitrary)+        , ObjectExt    <$> arbitrary <*> (S.pack <$> arbitrary)+        ]+        where negatives = Gen.choose (minBound, -1)
+ test/Data/MessagePack/ArbitrarySpec.hs view
@@ -0,0 +1,14 @@+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE Trustworthy         #-}+module Data.MessagePack.ArbitrarySpec where++import           Data.MessagePack.Arbitrary ()+import           Data.MessagePack.Types     (Object (..))+import           Test.Hspec                 (Spec, describe, it, shouldBe)+import           Test.QuickCheck            (Arbitrary (..), property)++spec :: Spec+spec =+    describe "arbitrary" $+        it "produces reasonably-sized objects" $+            property $ \(x :: Object) -> read (show x) `shouldBe` x
+ test/testsuite.hs view
@@ -0,0 +1,1 @@+{-# OPTIONS_GHC -F -pgmF hspec-discover #-}