@@ -112,6 +112,9 @@ isTaggedObjectValue (Object obj) = "tag" `H.member` obj &&
112112 "contents" `H.member` obj
113113isTaggedObjectValue _ = False
114114
115+isNullaryTaggedObject :: Value -> Bool
116+isNullaryTaggedObject obj = isTaggedObject obj && isObjectWithSingleField obj
117+
115118isTaggedObject :: Value -> Bool
116119isTaggedObject (Object obj) = "tag" `H.member` obj
117120isTaggedObject _ = False
@@ -166,12 +169,60 @@ tests = testGroup "properties" [
166169 , testGroup "failure messages" [
167170 testProperty "modify failure" modifyFailureProp
168171 ]
172+ , testGroup "generic" [
173+ testGroup "toJSON" [
174+ testGroup "Nullary" [
175+ testProperty "string" (isString . gNullaryToJSONString)
176+ , testProperty "2ElemArray" (is2ElemArray . gNullaryToJSON2ElemArray)
177+ , testProperty "TaggedObject" (isNullaryTaggedObject . gNullaryToJSONTaggedObject)
178+ , testProperty "ObjectWithSingleField" (isObjectWithSingleField . gNullaryToJSONObjectWithSingleField)
179+ , testGroup "roundTrip" [
180+ testProperty "string" (toParseJSON gNullaryParseJSONString gNullaryToJSONString)
181+ , testProperty "2ElemArray" (toParseJSON gNullaryParseJSON2ElemArray gNullaryToJSON2ElemArray)
182+ , testProperty "TaggedObject" (toParseJSON gNullaryParseJSONTaggedObject gNullaryToJSONTaggedObject)
183+ , testProperty "ObjectWithSingleField" (toParseJSON gNullaryParseJSONObjectWithSingleField gNullaryToJSONObjectWithSingleField)
184+ ]
185+ ]
186+ , testGroup "SomeType" [
187+ testProperty "2ElemArray" (is2ElemArray . gSomeTypeToJSON2ElemArray)
188+ , testProperty "TaggedObject" (isTaggedObject . gSomeTypeToJSONTaggedObject)
189+ , testProperty "ObjectWithSingleField" (isObjectWithSingleField . gSomeTypeToJSONObjectWithSingleField)
190+ , testGroup "roundTrip" [
191+ testProperty "2ElemArray" (toParseJSON gSomeTypeParseJSON2ElemArray gSomeTypeToJSON2ElemArray)
192+ , testProperty "TaggedObject" (toParseJSON gSomeTypeParseJSONTaggedObject gSomeTypeToJSONTaggedObject)
193+ , testProperty "ObjectWithSingleField" (toParseJSON gSomeTypeParseJSONObjectWithSingleField gSomeTypeToJSONObjectWithSingleField)
194+ ]
195+ ]
196+ ]
197+ , testGroup "toEncoding" [
198+ testProperty "NullaryString" $
199+ gNullaryToJSONString `sameAs` gNullaryToEncodingString
200+ , testProperty "Nullary2ElemArray" $
201+ gNullaryToJSON2ElemArray `sameAs` gNullaryToEncoding2ElemArray
202+ , testProperty "NullaryTaggedObject" $
203+ gNullaryToJSONTaggedObject `sameAs` gNullaryToEncodingTaggedObject
204+ , testProperty "NullaryObjectWithSingleField" $
205+ gNullaryToJSONObjectWithSingleField `sameAs`
206+ gNullaryToEncodingObjectWithSingleField
207+ -- , testProperty "ApproxUnwrap" $
208+ -- gApproxToJSONUnwrap `sameAs` gApproxToEncodingUnwrap
209+ , testProperty "ApproxDefault" $
210+ gApproxToJSONDefault `sameAs` gApproxToEncodingDefault
211+ , testProperty "SomeType2ElemArray" $
212+ gSomeTypeToJSON2ElemArray `sameAsV` gSomeTypeToEncoding2ElemArray
213+ , testProperty "SomeTypeTaggedObject" $
214+ gSomeTypeToJSONTaggedObject `sameAsV` gSomeTypeToEncodingTaggedObject
215+ , testProperty "SomeTypeObjectWithSingleField" $
216+ gSomeTypeToJSONObjectWithSingleField `sameAsV`
217+ gSomeTypeToEncodingObjectWithSingleField
218+ ]
219+ ]
169220 , testGroup "template-haskell" [
170221 testGroup "toJSON" [
171222 testGroup "Nullary" [
172223 testProperty "string" (isString . thNullaryToJSONString)
173224 , testProperty "2ElemArray" (is2ElemArray . thNullaryToJSON2ElemArray)
174− , testProperty "TaggedObject" (isTaggedObjectValue . thNullaryToJSONTaggedObject)
225+ , testProperty "TaggedObject" (isNullaryTaggedObject . thNullaryToJSONTaggedObject)
175226 , testProperty "ObjectWithSingleField" (isObjectWithSingleField . thNullaryToJSONObjectWithSingleField)
176227
177228 , testGroup "roundTrip" [