Permalink
Browse files

Reorganized package; run tests with cabal

  • Loading branch information...
1 parent 7b28ee7 commit d07e4acd870b11b7f097a748473355f9468ab508 @timjb timjb committed Mar 19, 2012
View
1 .gitignore
@@ -1 +1,2 @@
+cabal-dev
dist
View
18 operational-transformation.cabal
@@ -24,11 +24,21 @@ Cabal-version: >=1.2
Library
- Exposed-modules: OperationalTransformation, TestOperationalTransformation
+ Ghc-options: -Wall
+ Hs-source-dirs: src
+ Exposed-modules: Text.OperationalTransformation
Build-depends: base >= 4 && < 5,
- text >= 0.11.1 && < 0.12,
- QuickCheck >= 2.4.2 && < 2.5
+ text >= 0.11.1 && < 0.12
-- Modules not exported by this package.
-- Other-modules:
-
+
+Test-suite tests
+ Ghc-options: -Wall
+ Hs-source-dirs: src test
+ type: exitcode-stdio-1.0
+ main-is: TestOperationalTransformation.hs
+ Build-depends: QuickCheck >= 2.4.2 && < 2.5,
+ -- Copy pasted from library dependencies
+ base >= 4 && < 5,
+ text >= 0.11.1 && < 0.12
View
2 OperationalTransformation.hs → src/Text/OperationalTransformation.hs
@@ -1,6 +1,6 @@
{-# LANGUAGE OverloadedStrings #-}
-module OperationalTransformation
+module Text.OperationalTransformation
( Action(..)
, Operation
, merge
View
10 TestOperationalTransformation.hs → test/TestOperationalTransformation.hs
@@ -1,6 +1,6 @@
{-# LANGUAGE OverloadedStrings #-}
-import OperationalTransformation
+import Text.OperationalTransformation
import Test.QuickCheck
import qualified Data.Text as T
@@ -23,15 +23,15 @@ instance Arbitrary TextOperationPair where
return $ SOP text operation
-- | has at least 1 element
-arbitraryList :: (Arbitrary a) => Gen [a]
-arbitraryList = liftM2 (:) arbitrary arbitrary
+arbitraryList1 :: (Arbitrary a) => Gen [a]
+arbitraryList1 = liftM2 (:) arbitrary arbitrary
arbitraryOperation :: T.Text -> Gen Operation
-arbitraryOperation "" = oneof [return [], liftM ((:[]) . Insert . fromString) arbitraryList]
+arbitraryOperation "" = oneof [return [], liftM ((:[]) . Insert . fromString) arbitraryList1]
arbitraryOperation s = do
len <- choose (1, (min 10 (T.length s)))
oneof [ liftM ((Skip len):) $ arbitraryOperation (T.drop len s)
- , do s2 <- liftM2 ((.) (.) (.) fromString (:)) arbitrary arbitrary -- make sure that the text has a length of at least one
+ , do s2 <- liftM fromString arbitraryList1 -- make sure that the text has a length of at least one
next <- arbitraryOperation s
return $ (Insert s2):next
, do let (before, after) = T.splitAt len s

0 comments on commit d07e4ac

Please sign in to comment.