@@ -52,14 +52,30 @@ data User = User
52 { userFirstName :: Text
52 { userFirstName :: Text
53 , userLastName :: Text
53 , userLastName :: Text
54 } deriving (Eq, Ord, Show, Generic, NFData, Binary, Atomable)
54 } deriving (Eq, Ord, Show, Generic, NFData, Binary, Atomable)
56+data Test9_4T = Test9_4C {
61+ deriving (Show, Generic, Eq, Binary, NFData, Atomable)
63+data Test9_5T = Test9_5C {
70+ deriving (Show, Generic, Eq, Binary, NFData, Atomable)
56main :: IO ()
72main :: IO ()
58 tcounts <- runTestTT testList
74 tcounts <- runTestTT testList
59 if errors tcounts + failures tcounts > 0 then exitFailure else exitSuccess
75 if errors tcounts + failures tcounts > 0 then exitFailure else exitSuccess
61testList :: Test
77testList :: Test
62−testList = TestList [testHaskell2DB, testADT1, testADT2, testADT3, testADT4, testADT5, testBasicMarshaling, testListInstance, testNonEmptyInstance, testADT6Maybe, testADT7Either, testNonPrimitiveValues, testRecordType]
78+testList = TestList [testHaskell2DB, testADT1, testADT2, testADT3, testADT4, testADT5, testBasicMarshaling, testListInstance, testNonEmptyInstance, testADT6Maybe, testADT7Either, testNonPrimitiveValues, testRecordType, testManyFields]
64-- test some basic data types like int, day, etc.
80-- test some basic data types like int, day, etc.
65testBasicMarshaling :: Test
81testBasicMarshaling :: Test
@@ -163,3 +179,13 @@ testRecordType = TestCase $ do
163 let expected = AddTypeConstructor (ADTypeConstructorDef "User" []) [DataConstructorDef "User" [DataConstructorDefTypeConstructorArg (PrimitiveTypeConstructor "Text" TextAtomType),DataConstructorDefTypeConstructorArg (PrimitiveTypeConstructor "Text" TextAtomType)]]
179 let expected = AddTypeConstructor (ADTypeConstructorDef "User" []) [DataConstructorDef "User" [DataConstructorDefTypeConstructorArg (PrimitiveTypeConstructor "Text" TextAtomType),DataConstructorDefTypeConstructorArg (PrimitiveTypeConstructor "Text" TextAtomType)]]
165 assertEqual "User record to database context expr" expected (toAddTypeExpr (Proxy :: Proxy User))
181 assertEqual "User record to database context expr" expected (toAddTypeExpr (Proxy :: Proxy User))
183+--test both odd and even product types with more than 2 fields
184+testManyFields :: Test
185+testManyFields = TestCase $ do
186+ let example4 = Test9_4C 1 2 3 4
187+ assertEqual "four fields product type" example4 (fromAtom (toAtom example4))
189+ let example5 = Test9_5C 1 2 3 4 5
190+ assertEqual "five fields product type" example5 (fromAtom (toAtom example5))