FlorianHartwig avatar FlorianHartwig committed 9f4508c Draft

Cabalise the project.

Comments (0)

Files changed (4)

AttoBencode.cabal

+Name:                AttoBencode
+Version:             0.1
+Synopsis:            Fast Bencode encoding and parsing library
+Homepage:            http://bitbucket.org/FlorianHartwig/attobencode
+License:             BSD3
+License-file:        LICENSE
+Author:              Florian Hartwig <florian.j.hartwig@gmail.com>
+Maintainer:          Florian Hartwig <florian.j.hartwig@gmail.com>
+Category:            Data
+Build-type:          Simple
+Cabal-version:       >=1.8
+Library
+  Exposed-modules:
+    Data.AttoBencode,
+    Data.AttoBencode.Parser
+  
+  Other-modules:
+    Data.AttoBencode.Encode,
+    Data.AttoBencode.Types
+
+  Build-depends:
+    attoparsec,
+    base,
+    blaze-builder,
+    blaze-textual,
+    bytestring,
+    containers
+  
+  Ghc-options: -O2 -Wall 
+  Hs-source-dirs: src
+
+Test-suite tests
+  Type:           exitcode-stdio-1.0
+  Hs-source-dirs: tests
+  Main-is:        qc.hs
+  Build-depends:  AttoBencode,
+                  base,
+                  bytestring,
+                  containers,
+                  test-framework,
+                  test-framework-quickcheck2,
+                  QuickCheck >= 2.4 && < 2.5
+
+source-repository head
+  Type: mercurial
+  Location: https://bitbucket.org/FlorianHartwig/attobencode
+Copyright (c)2012, Florian Hartwig
+
+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 Florian Hartwig nor the names of other
+      contributors may be used to endorse or promote products derived
+      from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"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 THE COPYRIGHT
+OWNER OR CONTRIBUTORS 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.
+import Distribution.Simple
+main = defaultMain
 import Data.AttoBencode
 import Control.Monad (liftM)
 import Data.Map (Map, fromList)
+import Test.Framework (Test, defaultMain)
+import Test.Framework.Providers.QuickCheck2 (testProperty)
 import qualified Data.ByteString.Char8 as B
 
 instance Arbitrary BValue where
 instance Arbitrary B.ByteString where
     arbitrary   = fmap B.pack arbitrary
 
-encodeInteger :: Integer -> Bool
-encodeInteger n = encode (BInt n) == B.pack ("i" ++ show n ++ "e")
+prop_EncodeInteger :: Integer -> Bool
+prop_EncodeInteger n = encode (BInt n) == B.pack ("i" ++ show n ++ "e")
 
-encodeString :: B.ByteString -> Bool
-encodeString bs =
+prop_EncodeString :: B.ByteString -> Bool
+prop_EncodeString bs =
     encode (BString bs) == B.pack (show (B.length bs) ++ ":") `B.append` bs
 
-prop_encodeDecode bv = case decode (encode bv) of
+prop_EncodeDecode bv = case decode (encode bv) of
                             Just bv' -> bv == bv'
                             Nothing  -> False
 
 main :: IO ()
-main = quickCheck encodeInteger
-       >> quickCheck encodeString
-       >> quickCheck prop_encodeDecode
+main = defaultMain tests
+
+tests :: [Test]
+tests = [testProperty "prop_EncodeInteger" prop_EncodeInteger
+        ,testProperty "prop_EncodeString" prop_EncodeString
+        ,testProperty "prop_EncodeDecode" prop_EncodeDecode]
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.