summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authordefanor <defanor@uberspace.net>2017-12-16 07:55:35 +0300
committerdefanor <defanor@uberspace.net>2017-12-16 08:42:20 +0300
commitfa15e16722ece1b429a6f45d6f57d77e528fe825 (patch)
tree38f900588d6613eedbd18d0a7d66fba88569bcb1 /test
parent6ca0662862dffcc67ff4016aaa04cf314d81608e (diff)
Refactor
- Unify the naming - Merge all the classes into one
Diffstat (limited to 'test')
-rw-r--r--test/Test.hs53
1 files changed, 15 insertions, 38 deletions
diff --git a/test/Test.hs b/test/Test.hs
index ffcae8e..9b92993 100644
--- a/test/Test.hs
+++ b/test/Test.hs
@@ -1,4 +1,4 @@
-{-# LANGUAGE DeriveGeneric #-}
+{-# LANGUAGE DeriveGeneric, DeriveAnyClass #-}
import GHC.Generics
import Generic.Random
@@ -11,15 +11,11 @@ import Coalpit
data Basic = Basic Int String Double
- deriving (Generic, Eq, Show)
-instance ArgParser Basic
-instance ToArgs Basic
+ deriving (Generic, Eq, Show, Coalpit)
instance Arbitrary Basic where arbitrary = genericArbitraryU
data WithLists = WithLists [Int] [String] [Double]
- deriving (Generic, Eq, Show)
-instance ArgParser WithLists
-instance ToArgs WithLists
+ deriving (Generic, Eq, Show, Coalpit)
instance Arbitrary WithLists where arbitrary = genericArbitraryU
data Record = Record { maybeInt :: Maybe Int
@@ -28,62 +24,47 @@ data Record = Record { maybeInt :: Maybe Int
, listOfStrings :: [String]
, maybeListOfNumbers :: Maybe [Integer]
, otherString :: String
- } deriving (Generic, Eq, Show)
-instance ArgParser Record
-instance ToArgs Record
+ } deriving (Generic, Eq, Show, Coalpit)
instance Arbitrary Record where arbitrary = genericArbitraryU
data Sum = Foo Int Bool
| Bar
| Baz (String, (Double, Integer), Rational)
- deriving (Generic, Eq, Show)
-instance ArgParser Sum
-instance ToArgs Sum
+ deriving (Generic, Eq, Show, Coalpit)
instance Arbitrary Sum where arbitrary = genericArbitraryU
data Nested = Nested Record Basic WithLists Sum
- deriving (Generic, Eq, Show)
-instance ArgParser Nested
-instance ToArgs Nested
+ deriving (Generic, Eq, Show, Coalpit)
instance Arbitrary Nested where arbitrary = genericArbitraryU
data Polymorphic a b = Polymorphic (Maybe a) [b] (Either a b)
deriving (Generic, Eq, Show)
-instance (ArgParser a, ArgParser b) => ArgParser (Polymorphic a b)
-instance (ToArgs a, ToArgs b) => ToArgs (Polymorphic a b)
+instance (Coalpit a, Coalpit b) => Coalpit (Polymorphic a b)
instance (Arbitrary a, Arbitrary b) => Arbitrary (Polymorphic a b) where
arbitrary = genericArbitraryU
data Recursive = RecursiveA
| RecursiveB Recursive
- deriving (Generic, Eq, Show)
-instance ArgParser Recursive
-instance ToArgs Recursive
+ deriving (Generic, Eq, Show, Coalpit)
instance Arbitrary Recursive where arbitrary = genericArbitraryU
data NestedRecord = NestedRecord { record1 :: Maybe Record
, record2 :: Maybe Record
, record3 :: Maybe Record
- } deriving (Generic, Eq, Show)
-instance ArgParser NestedRecord
-instance ToArgs NestedRecord
+ } deriving (Generic, Eq, Show, Coalpit)
instance Arbitrary NestedRecord where arbitrary = genericArbitraryU
data NestedSum = NestedFoo Record
| NestedBar Sum Basic Nested
| NestedBaz (Polymorphic Int Double)
- deriving (Generic, Eq, Show)
-instance ArgParser NestedSum
-instance ToArgs NestedSum
+ deriving (Generic, Eq, Show, Coalpit)
instance Arbitrary NestedSum where arbitrary = genericArbitraryU
data RecursiveRecordMaybe = RecursiveRecordMaybe
{ rrm :: Maybe RecursiveRecordMaybe
, record :: Maybe Record
, guard :: ()
- } deriving (Generic, Eq, Show)
-instance ArgParser RecursiveRecordMaybe
-instance ToArgs RecursiveRecordMaybe
+ } deriving (Generic, Eq, Show, Coalpit)
instance Arbitrary RecursiveRecordMaybe where arbitrary = genericArbitraryU
data RecursiveRecordMaybe2 = RecursiveRecordMaybe2
@@ -91,25 +72,21 @@ data RecursiveRecordMaybe2 = RecursiveRecordMaybe2
, rrm' :: Maybe RecursiveRecordMaybe2
, record2' :: Maybe Record
, guard' :: ()
- } deriving (Generic, Eq, Show)
-instance ArgParser RecursiveRecordMaybe2
-instance ToArgs RecursiveRecordMaybe2
+ } deriving (Generic, Eq, Show, Coalpit)
instance Arbitrary RecursiveRecordMaybe2 where arbitrary = genericArbitraryU
data RecordStrings = RecordStrings
{ s1 :: String
, s2 :: String
, s3 :: String
- } deriving (Generic, Eq, Show)
-instance ArgParser RecordStrings
-instance ToArgs RecordStrings
+ } deriving (Generic, Eq, Show, Coalpit)
instance Arbitrary RecordStrings where arbitrary = genericArbitraryU
-printAndParse :: (ArgParser a, ToArgs a, Eq a)
+printAndParse :: (Coalpit a, Eq a)
=> Options -> Proxy a -> a -> Bool
printAndParse m _ r = Right r == fromArgs m (toArgs m r)
-mkTest :: (ArgParser a, ToArgs a, Eq a, Show a, Arbitrary a)
+mkTest :: (Coalpit a, Eq a, Show a, Arbitrary a)
=> Options -> Proxy a -> String -> TestTree
mkTest m p n = QC.testProperty n (printAndParse m p)