@@ -1,5 +1,5 @@
1--Test Atomable typeclass which allows users to use existing Haskell datatypes to marshal them to and from the database as ConstructedAtoms.
1--Test Atomable typeclass which allows users to use existing Haskell datatypes to marshal them to and from the database as ConstructedAtoms.
2−{-# LANGUAGE DeriveGeneric, DeriveAnyClass, OverloadedStrings #-}
2+{-# LANGUAGE DeriveGeneric, DeriveAnyClass, OverloadedStrings, TypeApplications #-}
3import Test.HUnit
3import Test.HUnit
4import ProjectM36.Client
4import ProjectM36.Client
5import Data.Binary
5import Data.Binary
@@ -75,7 +75,7 @@ main = do
75 if errors tcounts + failures tcounts > 0 then exitFailure else exitSuccess
75 if errors tcounts + failures tcounts > 0 then exitFailure else exitSuccess
77testList :: Test
77testList :: Test
78−testList = TestList [testHaskell2DB, testADT1, testADT2, testADT3, testADT4, testADT5, testBasicMarshaling, testListInstance, testNonEmptyInstance, testADT6Maybe, testADT7Either, testNonPrimitiveValues, testRecordType, testManyFields]
78+testList = TestList [testHaskell2DB, testADT1, testADT2, testADT3, testADT4, testADT5, testBasicMarshaling, testSimpleList, testListInstance, testNonEmptyInstance, testADT6Maybe, testADT7Either, testNonPrimitiveValues, testRecordType, testManyFields]
80-- test some basic data types like int, day, etc.
80-- test some basic data types like int, day, etc.
81testBasicMarshaling :: Test
81testBasicMarshaling :: Test
@@ -160,6 +160,12 @@ testListInstance = TestCase $ do
160 let example = TestListC [3,4,5]
160 let example = TestListC [3,4,5]
161 assertEqual "List instance" example (fromAtom (toAtom example))
161 assertEqual "List instance" example (fromAtom (toAtom example))
163+testSimpleList :: Test
164+testSimpleList = TestCase $ do
165+ let example = toAtom @[Integer] [1,2,3]
166+ expected = ConstructedAtom "Cons" (ConstructedAtomType "List" (M.fromList [("a",IntegerAtomType)])) [IntegerAtom 1,ConstructedAtom "Cons" (ConstructedAtomType "List" (M.fromList [("a",IntegerAtomType)])) [IntegerAtom 2,ConstructedAtom "Cons" (ConstructedAtomType "List" (M.fromList [("a",IntegerAtomType)])) [IntegerAtom 3,ConstructedAtom "Empty" (ConstructedAtomType "List" (M.fromList [("a",IntegerAtomType)])) []]]]
167+ assertEqual "simple list" expected example
163testNonEmptyInstance :: Test
169testNonEmptyInstance :: Test
164testNonEmptyInstance = TestCase $ do
170testNonEmptyInstance = TestCase $ do
165 let example = TestNonEmptyC [3,4,5]
171 let example = TestNonEmptyC [3,4,5]